addEventListener
是否会覆盖之前为特定事件定义的操作?例如,
<input type="text" name="ele" id="eleID" onfocus="doSomeThing();"/>
现在如果我为同一个事件添加另一个 Action ,这两个函数都会被执行吗?
eleID.addEventListener('focus',doSomethingElse,false);
如果 doSomethingElse()
覆盖了 doSomeThing()
,还有其他方法吗?
最佳答案
没有。
From MDC :
addEventListener is the way to register an event listener as specified in W3C DOM. Its benefits are as follows:
- It allows adding more than a single handler for an event.
关于javascript - addEventListener 覆盖其他事件 Action ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6227667/