jquery 停止事件冒泡方法
2012-08-27 11:22
267 查看
2种方法:
View Code
View Code
<script type="text/javascript"> $(function(){ // 为span元素绑定click事件 $('span').bind("click",function(event){ var txt = $('#msg').html() + "<p>内层span元素被点击.<p/>"; $('#msg').html(txt); event.stopPropagation(); // 阻止事件冒泡 }); // 为div元素绑定click事件 $('#content').bind("click",function(event){ var txt = $('#msg').html() + "<p>外层div元素被点击.<p/>"; $('#msg').html(txt); event.stopPropagation(); // 阻止事件冒泡 }); // 为body元素绑定click事件 $("body").bind("click",function(){ var txt = $('#msg').html() + "<p>body元素被点击.<p/>"; $('#msg').html(txt); }); })
相关文章推荐
- jquery mouseout事件冒泡解决方法
- jquery阻止事件冒泡的两种方法 .
- jquery对事件冒泡的处理方法
- JS,Jquery中事件冒泡以及阻止事件冒泡方法
- jQuery阻止冒泡事件的几种方法
- jQuery中阻止冒泡事件的方法介绍
- js阻止浏览器的默认行为以及停止事件冒泡(用JQuery实现回车提交)
- js /jquery停止事件冒泡和阻止浏览器默认事件
- jquery关于事件冒泡和事件委托的技巧及阻止与允许事件冒泡的三种实现方法
- JS:停止事件冒泡和阻止浏览器的默认行为 js/jquery/prototype
- 停止冒泡事件的方法(已兼容)
- js阻止浏览器的默认行为以及停止事件冒泡(用JQuery实现回车提交,兼容IE、FF浏览器) 转
- jQuery停止事件冒泡
- js阻止浏览器的默认行为以及停止事件冒泡(用JQuery实现回车提交,兼容IE、FF浏览器)
- jQuery中处理事件冒泡的方法和取消后续内容的方法
- jQuery阻止 toggle方法事件冒泡
- js阻止浏览器的默认行为以及停止事件冒泡(用JQuery实现回车提交,兼容IE、FF浏览器)
- jQuery的的方法阻止冒泡和默认的事件(三种方法)
- js阻止浏览器的默认行为以及停止事件冒泡(用JQuery实现回车提交,兼容IE、FF浏览器)
- jquery取消事件冒泡的三种方法