笔记
event.currentTarget
和event.target
的区别
-
currentTarget
事件处理的元素 -
target
触发此事件的元素
function hide(e){
e.currentTarget.style.visibility = "hidden";
// When this function is used as an event handler:
this === e.currentTarget
}
var ps = document.getElementsByTagName('p');
for(var i = 0; i < ps.length; i++){
//false -> 停止事件冒泡
ps[i].addEventListener('click', hide, false);
}