Side navigation
#2900 closed bug (invalid)
Opened May 19, 2008 10:39PM UTC
Closed May 20, 2008 01:56AM UTC
Last modified March 15, 2012 06:09PM UTC
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: | |
| Blocked by: | Blocking: |
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>
Attachments (0)
Change History (1)
Changed May 20, 2008 01:56AM UTC by comment:1
| resolution: | → invalid |
|---|---|
| status: | new → closed |
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.