<span style="font-size:18px;"><script type="text/javascript">
$(function() {
$("div").on("click",divClickHandler);
//$("div").on("click",divClickHandler1);
$(document).on("click",documentClickHandler);
});
function divClickHandler(e) {
console.log("div->click");
$(this).css("background","green");
// event.stopPropagation(); 阻止父类冒泡
// event.stopImmediatePropagation();
console.log(e);
return false;
}
function divClickHandler1(e) {
console.log("div->click1");
// event.stopPropagation(); //阻止父类冒泡
// event.stopImmediatePropagation();
console.log(e);
//return false;
}
function documentClickHandler(e) {
$("*").css("background","gray");
console.log("document- >click");
console.log($(this));
}
</script>
</head>
<body>
<div style="width:300px;height:200px;border:1px solid red">
</div>
</body>
</span>
jQuery冒泡事件
最新推荐文章于 2024-08-17 15:56:45 发布