我希望做事件委托并通过绑定到整个文档的事件处理程序捕获发生在DOM对象上的所有事件。将事件绑定到window
与绑定到以下代码中有什么区别:
window.addEventListener(event, function(e){
var obj = e.target;
... // if `obj` is a certain kind of object, then do something
}, false);
您是想翻译以下内容中的window.document
吗?
window.document.addEventListener(event, function(e){
var obj = e.target;
... // if `obj` is a certain kind of object, then do something
}, false);
event
是一些事件,例如 'click'
, 'mouseover'
等。