Prevent click event from affecting parent jquery

血红的双手。 提交于 2019-12-01 20:56:33

stopPropagation has problems with live, from the jQuery stopPropagation docs -

Since the .live() method handles events once they have propagated to the top of the document, it is not possible to stop propagation of live events

As Rob W has said your code would work fine with bind, here's a demo - http://jsfiddle.net/TmKyT/

Use .bind instead of .live. The live event is triggered at the end of the propagation tree. live is only more useful than bind when you want to also bind the event listener for elements which are created later.

moleculezz

Maybe try using delegate?

$('ul.parent').delegate('li a[rel=close]', 'click', function( event ) {

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