读书人

基准dom模型事件捕获

发布时间: 2012-11-12 12:31:57 作者: rapoo

标准dom模型事件捕获

<!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">#a {background-color: #933;float: left;height: 90px;width: 90px;}#b {background-color: #655;height: 60px;width: 60px;}#c {background-color: #334;height: 30px;width: 30px;}#d {background-color: #489;float: right;height: 30px;width: 30px;}</style></head><body><div id="a">a<div id="b">b<div id="c">c</div></div></div><div id="d">d</div><script type="text/javascript"><!--var a=document.getElementById("a");var b=document.getElementById("b");var c=document.getElementById("c");var d=document.getElementById("d");a.addEventListener("click",function(){alert("a")},0);b.addEventListener("click",function(){alert("b")},1);c.addEventListener("click",function(){alert("c")},0);d.addEventListener("click",function(){alert("d")},0);//--></script></body></html>

?

?

b.addEventListener("click",function(){alert("a")},0);

当最后一个参数是1,点击c的时候,在顺事件流中则b不捕获,证明b不拦截

?

读书人网 >Web前端

热点推荐