live change handlers in jQuery 1.4 don't work for select elements in IE

混江龙づ霸主 提交于 2019-12-13 03:50:52

问题


I recently decided to try jQuery 1.4, excited that I would finally have support for live event handlers that work for change events in IE. However, it seems like they don't always work. If I try to assign a live change handler on a select element, it doesn't work when I change it in IE.

I tried this in IE 6, 7, and 8. In every other browser I tried (Firefox, Chrome, Safari), it works fine. I tried putting the command to assign the handler within the ready function, and that didn't fix it.

Does anyone have any idea what is causing this or what I can do to fix it? Am I doing something wrong, or is this a bug in jQuery? Here is an example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<title>jQuery live change handler test</title>
</head>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<select id="test">
    <option value="a">a
    <option value="b">b
</select>
<script type="text/javascript">
$("#test").live("change", function() {
    alert('hi');
});
</script>
</body></html>

回答1:


Looks like it has been fixed. Not sure when it goes live.

Ticket - http://dev.jquery.com/ticket/5851

GitHub commit - http://github.com/jquery/jquery/commit/435772e29b4ac4ccfdefbc4045d43f714e153381




回答2:


from here

Possible event values: click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup

Currently not supported: blur, focus, mouseenter, mouseleave, change, submit

change, my friend, is not yet supported by live



来源:https://stackoverflow.com/questions/2105206/live-change-handlers-in-jquery-1-4-dont-work-for-select-elements-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!