Jquery click event propagation

风流意气都作罢 提交于 2019-11-28 09:51:15
rahul

You have to stop event bubbling. In jQuery you can do this by

e.stopPropagation();

in the onclick event of the anchor tag.

$("a").live("click",function(e){alert("clicked!");e.stopPropagation();});

Edit

See this post

jquery Event.stopPropagation() seems not to work

I would use bind instead of live for both <tr> and <a> and the following code

$("a").bind("click", function(e){ alert("clicked!"); e.stopPropagation() });

for <a>.

All <a href>'s will work as expected and <tr> event handler code won't execute after clicking <a>.

Works in all modern browsers.

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