js事件的相关收集

1.阻止事件冒泡:

IE:cancelBubble = true;

其他: stopPropagation();

2.阻止事件的默认行为:

IE: returnValue = false;

其他: preventDefault();

3.事件源:

IE:srcElement

其他:target(目标元素) currentTarget(绑定时间的元素)

4.注册事件的写法

 DOM0级到DOM2级事件注册方式:

0级:<button onclick="alert(1)" value="点击"/>

1级:  document.getElementById().onclick = function(){}

2级:

IE:window.attachEvent('onclick',callback,false);

其他: window.addEventListener('click',callback,false);

原文地址:https://www.cnblogs.com/freefish12/p/5396809.html