addEventListener是否会覆盖其他事件操作? [英] addEventListener overwrites other event actions?
本文介绍了addEventListener是否会覆盖其他事件操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
addEventListener是否会覆盖以前为特定事件定义的操作?例如,
Does addEventListener overwrites previously defined actions for a particular event?For example,
<input type="text" name="ele" id="eleID" onfocus="doSomeThing();"/>
现在,如果我为同一事件添加另一个动作,两个函数都会被执行吗?
Now if I add another action for the same event,will both both function get executed?
eleID.addEventListener('focus',doSomethingElse,false);
如果 doSomethingElse()
覆盖 doSomeThing()
,还有其他办法吗?
If doSomethingElse()
overwrites doSomeThing()
, is there any other way to do it?
推荐答案
没有。
来自MDC :
addEventListener是注册W3C DOM中指定的事件监听器的方法。它的好处如下:
addEventListener is the way to register an event listener as specified in W3C DOM. Its benefits are as follows:
- 它允许为事件添加多个处理程序。
查看示例。
这篇关于addEventListener是否会覆盖其他事件操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文