var h={
$(el){
return document.querySelectorAll(el)
},
addEl(el,type,fun){
if(el.addEventListener){
el.addEventListener(type,fun,false)
}else if(el.attachEvent){
el.attachEvent('on'+type,fun)
}else{
el['on'+type] =fun
}
},
getTarget(event){
return event.target || event.srcElement;
},
preDef(event){
if(event.preventDefault){
event.preventDefault()
}else{
event.returnValue=false;
}
}
}
var title = h.$('.title')[0]
h.addEl(title,'click',(e) => {
console.log(h.getTarget(e))
h.preDef(e)
})
网友评论