Modify ↓
Ticket #2900 (closed bug: invalid)
Change and Focus event handlers do not bind in IE7
| Reported by: | picardo | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.2.4 |
| Component: | event | Version: | 1.2.3 |
| Keywords: | change each internet explorer | Cc: | |
| Blocking: | Blocked by: |
Description
I noticed that binding a .change(fn) or a .focus(fn) to an array returned by .each in IE7 will give the warning that the "Object doesn't support this property or method." I have tested it only in Firefox, where it works fine, and IE7.
Enclosing a sample page I created to demonstrate this problem.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://dev.jquery.com/chrome/common/js/jquery.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#dd, #mm, #yyyy").each(jQuery(this).click(function(){
alert("I am a click event. I work in IE7");
})
);
jQuery("#dd, #mm, #yyyy").each(jQuery(this).change(function(){
alert("I am a change event. I don't work in IE7");
})
);
jQuery("#dd, #mm, #yyyy").each(jQuery(this).change(function(){
alert("I am a focus event. I don't work in IE7, either");
})
);
});
</script>
<title>Untitled Document</title>
</head>
<body>
<input id="dd" /><input id="mm" /><input id="yyyy" />
</body>
</html>
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Your code is wrong, try:
jQuery(document).ready(function(){ jQuery("#dd, #mm, #yyyy").click(function(){ alert("I am a click event. I work in IE7"); }); jQuery("#dd, #mm, #yyyy").change(function(){ alert("I am a change event. I don't work in IE7"); }); jQuery("#dd, #mm, #yyyy").focus(function(){ alert("I am a focus event. I don't work in IE7, either"); }); });Check the docs for better understanding. The click was accidentally working because the click event bubbles.