12.4默写

2017-12-03  本文已影响0人  css7
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';
    }
}

上一篇下一篇

猜你喜欢

热点阅读