标签:doctype onstop .com val on() 默认 code oct lib
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title></title> 6 </head> 7 <body> 8 <div id = "box" style = "width: 200px; height: 200px; background:green;"> 9 <input type="button" value = "按钮" /> 10 </div> 11 12 <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> 13 <script> 14 $(function () { 15 $("body").click(function () { 16 console.log("body"); 17 }); 18 $("#box").click(function () { 19 console.log("div"); 20 }); 21 $("input").click(function (e) { 22 console.log("input"); 23 24 e.stopPropagation();//阻止冒泡 25 console.log(e.isPropagationStopped);//true 26 27 e.preventDefault()//阻止浏览器默认行为 28 }) 29 }) 30 </script> 31 </body> 32 </html>
e.stopPropagation();//阻止冒泡 console.log(e.isPropagationStopped);//true e.preventDefault()//阻止浏览器默认行为
标签:doctype onstop .com val on() 默认 code oct lib
原文地址:http://www.cnblogs.com/1032473245jing/p/7504835.html