在addEventListener中为false? [英] false in addEventListener?
问题描述
这个属性是什么?
var el = document.getElementById(outside);
el.addEventListener(click,modifyText,false);
这就是 useCapture
参数。来自 文档
useCapture
可选
如果为true,则useCapture表示用户希望启动捕获。在启动捕获之后,指定类型的所有事件将被分派到注册的侦听器,然后被分派到DOM树下的任何EventTarget。向上冒泡树的事件不会触发指定使用捕获的侦听器。有关详细说明,请参阅DOM Level 3事件。如果未指定,则useCapture默认为false。
阅读关于此主题的更多信息 此处 。
in this below line: third parameter is kept false. what is this attribute??
var el = document.getElementById("outside");
el.addEventListener("click", modifyText, false);
That's the useCapture
parameter. From documentation
useCapture
OptionalIf true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree. Events which are bubbling upward through the tree will not trigger a listener designated to use capture. See DOM Level 3 Events for a detailed explanation. If not specified, useCapture defaults to false.
Read more about this topic here.
这篇关于在addEventListener中为false?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!