标签:ace -- 超链接 ext cli over otto 结果 syntax
(一)JS中的事件流模型
1. 事件冒泡(fasle/不写):当触发一个节点的事件是,会从当前节点开始,依次触发其祖先节点的同类型事件,直到DOM根节点。
2. 事件捕获(true):当初发一个节点的事件时,会从DOM根节点开始,依次触发其祖先节点的同类型事件,直到当前节点自身。
3. 什么时候事件冒泡?什么时候事件捕获?
① 当使用addEventListener绑定事件,第三个参数传为true时表示事件捕获;
② 除此之外的所有事件绑定均为事件冒泡。
4. 阻止事件冒泡:
① IE10之前,e.cancelBubble = true;
② IE10之后,e.stopPropagation();
5. 阻止默认事件:
① IE10之前:e.returnValue = false;
② IE10之后:e.preventDefault();
//css#div1{ width: 300px;; height: 300px; }#div2{ width: 200px; height: 200px; }#div3{ width: 100px; height: 100px; padding: 0px 0px 0px 5px; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border-left: 3px solid rgb(108, 226, 108); line-height: 20px; width: 640px; clear: both; outline: 0px !important; border-radius: 0px !important; border-top: 0px !important; border-right: 0px !important; border-bottom: 0px !important; border-image: initial !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; min-height: auto !important; color: gray !important;">#A9A9A9;}//html<div id="div1"> <div id="div2"> <div id="div3"></div> </div></div><a href="01-事件笔记.html" rel="external nofollow" onclick="func()">超链接</a>div1.addEventListener("click",function(){ console.log("div1 click");},false);div2.addEventListener("click",function(){ console.log("div2 click");},false);div3.addEventListener("click",function(){ //原来的顺序是:3-->2-->1。// myParagraphEventHandler(); //截获事件流后,只触发3.但是从2开始依然会冒泡; console.log("div3 click");},false);结果(事件冒泡)(由小到大div3-》div2-》div1):

结果(事件捕获)(由小到大div3-》div2-》div1):

标签:ace -- 超链接 ext cli over otto 结果 syntax
原文地址:https://www.cnblogs.com/login123/p/12130427.html