标签:log class 冒泡 顺序 html java event asc nload
冒泡事件就是有内到外,由下至上如冒泡般触发的顺序
window.onload = function() { //冒泡事件就是有内到外,由下至上如冒泡般触发的顺序 document.onclick = function(){ alert(‘document‘); }; document.documentElement.onclick = function(){ alert(‘HTML‘); }; document.body.onclick = function(){ alert(‘body‘); }; document.getElementById(‘box‘).onclick = function(){ alert(‘div‘); }; document.getElementById(‘input‘).onclick = function(evt){ //阻止冒泡需要stopPropagation()方法 var e = evt || window.event; alert(‘input‘); if(e.stopPropagation){ e.stopPropagation(); }else { e.cancelBubble = true; //IE兼容 } }; }
标签:log class 冒泡 顺序 html java event asc nload
原文地址:http://www.cnblogs.com/jackyhouse/p/6367156.html