冒泡和事件捕获
Last updated
Last updated
<script>
function stopPropagation(e) {
e = e || window.event;
if(e.stopPropagation) {
e.stopPropagation(); //W3C阻止冒泡方法
} else {
e.cancelBubble = true; //IE阻止冒泡方法
}
}
</script><script>
child.onclick = function (e) {
alert("你点击了child区域");
stopPropagation(e);
};
</script><script>
$("#parents").click(function () {
alert("你点击了parents区域")
});
$("#child").click(function () {
alert("你点击了child区域");
return false;
});
</script>