阻止冒泡:1、stopPropagation()对于非IE浏览器。2、cancelBubble属性为true,对于IE浏览器, 而Jquery已经有兼容浏览器的方法,event.stopImmediatePropagation(); 复制代码 代码如下: <br>body <br> { <br>background:black; <br> } <br>#myDiv <br> { <br>background: #fff; <br>width:250px; <br>height:250px; <br>display:none; <br> } <br> This is a div; <br> var myDiv = $("#myDiv"); <br>$(function () { <br>$("#btn").click(function (event) { <br>showDiv();//调用显示DIV方法 <br>$(document).one("click", function () {//对document绑定一个影藏Div方法 <br>$(myDiv).hide(); <br>}); <br>event.stopPropagation();//阻止事件向上冒泡 <br>}); <br>$(myDiv).click(function (event) { <br>event.stopPropagation();//阻止事件向上冒泡 <br>}); <br>}); <br> function showDiv() { <br>$(myDiv).fadeIn(); <br>} <br>