更新时间:2023-11-09 22:03:28
下面是一个启动示例
document.onclick = function(evt){
evt = evt || window.event;
var element = evt.target || evt.srcElement;
};
无论您在何处单击,都会获得对获得点击的元素的引用.
wherever you click you get a reference to the element that received the click.
在实际情况下,更有用的是使用 attachEvent
方法,或 addEventListener
其余.
More useful, though, in a real scenario would be to use the attachEvent
method for IE, or the addEventListener
for the rest.