首页 > 代码库 > 时间冒泡
时间冒泡
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#box{
width: 100%;
height: 600px;
background: red;
overflow: hidden;
}
#box1{
width: 80%;
height: 400px;
margin: 100px auto;
background: blue;
overflow: hidden;
}
#box2{
width: 60%;
height: 200px;
margin: 100px auto;
background: yellow;
}
</style>
</head>
<body>
<div id="box">
<div id="box1">
<div id="box2">
</div>
</div>
</div>
<script type="text/javascript">
var box = document.getElementById("box")
var box1 = document.getElementById("box1")
var box2 = document.getElementById("box2")
document.onclick = fn;
box.onclick =fn;
box1.onclick =fn;
box2.onclick =fn;
function fn ( ev ){
ev = ev|| event;
//ev.cancelBubble = true;
alert(this.id)
}
</script>
</body>
</html>
时间冒泡