1.什么是冒泡 eg:<!DOCTYPE html><html "http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type&qu ...
1.什么是冒泡
eg:
<!DOCTYPE html><html "http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>事件冒泡</title> <script src='/images/loading.gif' data-original="../../js/jQuery1.11.1.js"></script> <script type="text/javascript"> $(function () { //为span元素绑定click事件 $('span').bind('click', function () { var txt = $('#msg').html() + '<p>内层span元素被点击</p>'; $('#msg').html(txt); }); //为span元素绑定click事件 $('#content').bind('click', function () { var txt = $('#msg').html() + '<p>外层div元素被点击</p>'; $('#msg').html(txt); }); //为span元素绑定click事件 $('body').bind('click', function () { var txt = $('#msg').html() + '<p>body元素被点击</p>'; $('#msg').html(txt); }); }); </script></head><body> <div id="content"> 外层div元素 <span>内层span元素</span> </div> <div id="msg"></div></body></html>
也可以把事件冒泡中的event.stopPropagation(); //停止事件冒泡04.事件捕获
05.事件对象的属性
事件对象的属性 详情请参考:http://www.w3school.com.cn/jsref/dom_obj_event.asp
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:jQuery中的事件冒泡
关键词:jquery
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。