jQuery的停止事件冒泡现场 [英] jquery stop event bubbling with live

查看:103
本文介绍了jQuery的停止事件冒泡现场的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码

 var input = $("form input[name='name'].dhxlist_txt_textarea");

 $(input).live('click', function () {

       ShowLookupGrid();
 });

然后我在第一个执行绑定之前放置了第二个实时绑定

Then I've putted a second live binding before the first get executed

  $('#Id').live('click', function () {

       return false;
 });

但是return false语句不会停止将事件冒泡到第二个绑定.

But the return false statement isn't stoping bubbling up the event to the second binding.

推荐答案

只要这是运行的第一个事件处理程序,这应该停止在该元素上触发任何其他相同类型的事件.

This should stop any other events of the same type being fired on that element as long as it is the first event handler that is run.

$('#Id').live('click', function (event) {
   event.stopImmediatePropagation()
});

JSFiddle示例

这篇关于jQuery的停止事件冒泡现场的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆