12.4默写

  • 事件流
e.stopPropagation()/return false(只能使用在jq中)
阻止默认事件:return false
  • 事件监听
function (obj, eventType, fn) {
    if (obj.attachEvent) {
        obj.attachEvent('on' + eventType, fn);
    } else {
        obj.addEventListener(eventType, fn, false);
    }
}
  • 事件委托
oUl.onmouseover = function (event) {
    var event = event || window.event; 
    var target = event.target||event.srcElement;  
    var nodeName=target.nodeName;
    if(nodeName.toLowerCase()=='li'){
        target.style.background = 'green';
    }
}

你可能感兴趣的:(12.4默写)