为什么元素的*set_capture*会受到其父元素的*set_capture*的影响
why is the *set_capture* of an element affected by the *set_capture* of its parent?
为什么这个代码:
html:
<div id="outer" >
Outer Div
<div id="inner" >
Inner Div
</div>
</div>
加载:
document.getElementById("outer").addEventListener("mousedown", function() {
alert('outer');
}, true);
document.getElementById("inner").addEventListener("mousedown", function() {
alert('inner');
}, false);
http://jsfiddle.net/fGZ3U/
给我们一个警告outer
,然后是一个提醒inner
?
在inner的*use_capture*参数中,它被设置为false,这意味着事件应该从"inner"开始,不是吗?
我知道,如果我们将outer的*set_capture*设置为false,那么结果将是inner
,然后是outer
,但我看不出outer的*set_capture*值会对这里的结果产生什么影响。
不应该-use_capture参数集事件处理的哪一部分是该事件触发的
-
部分是捕获(use_capture=true)它从窗口开始到树中最深的元素
-
零件冒泡它从最深的元素开始,进入窗口
(在您的情况下,外部是第一个,因为它是在第一部分触发的)
http://www.quirksmode.org/js/events_order.html
相关文章:
- Firebase迁移-简单的Firebase.set没有'不再工作了——旧的还是新的
- Ember Data DS.Model's set函数不起作用
- C#asp.net mvc Set CheckBoxFor已检查的具有Model Value的属性
- 为什么JavaScript可以'找不到给定的InnerHTML并返回Cannot set property
- 无法在基于Cordova的应用程序中读取Set Cookie标头
- 在不兼容的接收器上调用的方法Set.prototype.add未定义
- 为什么可以't我用Set对象调用Array.prototype.map
- Sequelize associations:set[Models]添加新模型,而不是关联现有模型
- 如何使用选项useCSS set true为bxSlider加载onSlideAfter()事件
- Node JS,传统的数据结构?(如Set等),任何类似Java.util的node
- Bootstrap-Datepicker not selecting date when using "set
- Looking for function identical to lodash's [_.set]()
- Angular sqlLite set css url()无法设置相对路径
- Typerror:set 不是带有 angularjs 的函数
- 在使用 findAndModify 时$set运算符中将函数参数作为字段名称传递
- fabric.js:使用 Image.set() 调整图像大小是否会降低图像质量
- dataTransfer.set拖放的数据在chrome中不起作用
- 在 app.locals 上设置属性和调用 app.set() 有什么区别?
- console.log 在 CasperJS 的 set Timeout 评估中不起作用
- Backbone.js Visual Studio set up