<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>阻止冒泡</title>
<style type="text/css">
.block_opacity{
width: 100%;
height: 100%;
z-index: 1;
opacity: 0.5;
background: #cccccc;
filter: alpha(opacity=50);
top:0;
left: 0;
position: fixed;
display: none;
}
.block{
width: 400px;
height: 300px;
position: absolute;
margin-left: -200px;
margin-top: -150px;
top:50%;
left: 50%;
z-index: 2;
background:red;
display: none;
}
</style>
</head>
<body>
<div class="block_opacity" ></div>
<div class="block" ).show();
}

$(document).on("click",function(e){
var e=e || window.event;
var target=e.target || e.srcElement;
if(target.id=="bb") return;
$(".block_opacity,.block").hide();
});
//阻止时间冒泡
$("#block").click(function(e){
stopBubble(e);
});

function stopBubble(e){
if (e && e.stopPropagation)
e.stopPropagation();
else
window.event.cancelBubble=true;
}

</script>
</body>
</html>

相关文章:

  • 2021-11-05
  • 2021-09-30
  • 2021-12-15
  • 2022-12-23
  • 2021-08-09
  • 2021-07-16
  • 2021-08-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案