事件侦听函数
const EventUtils = { addEvent(element,type,handler){ if(element.addEventListener){ element.addEventListener(type,handler,false) }else if(element.attachEvent){ element.attachEvent(`on${type}`,handler) }else{ element[`on${type}`] = handler } }, removeEvent(elemnet,type,handler){ if(element.removeEventListener){ element.removeEventListener(type,handler,false) }else if(element.detachEvent){ element.detachEvent(`on${type}`,handler) }else{ element[`on${type}`] = null } }, getTarget(event){ return event || window.event }, stopPropagation(event){ if(event.stopPropagation){ event.stopPropagation() }else{ event.cancelBubble = true } }, preventDefault(event){ if(event.preventDefault){ event.preventDefault() }else{ event.returnValue = false } } }
#兼容版#
以自己现在的努力程度,还没有资格和别人拼天赋