1

我有以下片段按预期工作:

<a href="http://google.com" onclick="return false;">Will go to google</a>

点击href不会带我去谷歌。

但是......如果我包含 JQuery 1.4 并将实时点击事件连接到页面上的任何内容(无论它是否存在),这个不相关的事件处理程序将停止在 IE 中按预期工作(并继续在 firefox 和 chrome 中工作)。返回 false 被忽略,而是点击链接将您带到谷歌。

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script type='text/javascript'>
          //<![CDATA[
    $(document).ready(function() {
         $(".not-here").live("click", function() {alert("hi"); return false; });
    });
          //]]>
 </script>

这是怎么回事?我在 JQuery 1.4 版本中遇到过错误吗?

4

1 回答 1

3

是的,这是 JQuery 1.4 版本中的一个错误。它会影响任何使用现场活动的人。

由 John于 2010 年 1 月 24 日修补。它已在 2010 年 1 月 26 日发布的 JQuery 1.4.1 中修复。

见:http ://dev.jquery.com/ticket/5835

于 2010-01-25T22:24:27.787 回答