代码描述:jQuery阻止事件冒泡。jQuery阻止事件冒泡代码下载
关于事件冒泡的定义这里就不介绍了,具体可以参阅什么是jquery事件冒泡一章节。 下面直接给出一段阻止事件冒泡的实例代码,直接参考一下就可以了,代码如下:
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="https://www.51qianduan.com/" /> <title>事件冒泡-51前端</title> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#third").click(function(e){ alert("我是third"); e.stopPropagation(); }) $("#second").click(function(){ alert("我是second"); }) $("#first").click(function(){ alert("我是first"); }) }) </script> </head> <body> <div id="first"> <div id="second"> <a id="third" href="http://www.softwhy.com">点击查看效果</a> </div> </div> </body> </html>
请绑定手机号,在继续操作
注意:只有绑定手机以后,才可使用网站全部功能