jQuery 1.4 中的实时更改处理程序不适用于 IE 中的选择元素

发布于 2024-08-18 18:05:09 字数 974 浏览 7 评论 0原文

我最近决定尝试 jQuery 1.4,很高兴我终于能够支持适用于 IE 中更改事件的实时事件处理程序。然而,它们似乎并不总是有效。如果我尝试在选择元素上分配实时更改处理程序,则当我在 IE 中更改它时它不起作用。

我在 IE 6、7 和 8 中尝试过此操作。在我尝试过的所有其他浏览器(Firefox、Chrome、Safari)中,它运行良好。我尝试将命令放在就绪函数中分配处理程序,但这并没有解决问题。

有谁知道造成此问题的原因或我可以采取哪些措施来解决它?我做错了什么,或者这是 jQuery 中的一个错误?这是一个例子:

<!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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吲‖鸣 2024-08-25 18:05:09

看起来已经修复了。不确定什么时候上线。

票证 - http://dev.jquery.com/ticket/5851

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

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

少年亿悲伤 2024-08-25 18:05:09

来自此处

可能的事件值:click、dblclick、mousedown、mouseup , mousemove, mouseover, mouseout, keydown, keypress, keyup

当前不支持:blur, focus, mouseenter, mouseleave, change, 提交

更改,我的朋友,还不支持通过直播

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文