开发者

onclick event is broken in IE8

I have the following snippet which works as expected:

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

Clicking on the href does not take me to google.

But... if I include JQuery 1.4 and wire up a live click event to anything on the page (whether it exists or does not) this unrelated event handler stops working as expected in IE (and continues to work in firefox and chrome). Return false is ignored and instead clicking on the link takes you to google.

<script src="http://ajax.googleapis.com/ajax/开发者_C百科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>

Whats going on? Have I come across a bug in the JQuery 1.4 release.


Yes this is a bug in JQuery 1.4 Release. It affects anyone using the live events.

It was patched by John on the 24th of Jan 2010. It has been fixed in JQuery 1.4.1 which was released on the 26th of Jan 2010.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜