当前位置:网站首页>e. The difference between target and e.currenttarget
e. The difference between target and e.currenttarget
2022-07-27 04:28:00 【Nick_ Zhang】
<div id="big" class="big">
<div id="middle" class="middle">
</div>
</div>
.big {
background: red;
height: 50vh;
width: 50vh;
}
.middle {
background: green;
height: 30vh;
width: 30vh;
}
addEventListener The third parameter of indicates whether to capture , The default is false
true Means to execute capture ( From the outside in )
false Indicates execution bubbling ( From the inside out )
1. Executive bubbling
big.addEventListener('click', function (e) {
console.log("big--", "currentTarget:",e.currentTarget, "target:",e.target)
}, false)

middle.addEventListener('click', function (e) {
console.log("middle--", "currentTarget:",e.currentTarget, "target:",e.target)
}, false)

2. Execute capture
big.addEventListener('click', function (e) {
console.log("big--", "currentTarget:",e.currentTarget, "target:",e.target)
}, true)

middle.addEventListener('click', function (e) {
console.log("middle--", "currentTarget:",e.currentTarget, "target:",e.target)
}, true)

3. summary
target: The element that triggered the event
currentTarget: Event bound elements
When you click the parent element , Both point to the same element .
When you click on a child element , The event of the parent element will also trigger , At this time, the parent element event currentTarget Point to parent element ,target Point to child elements , The execution order is bubbling ( Father —— Son ), Capture ( Son —— Father ).
边栏推荐
- ASP语音通知接口对接demo
- Is VR panoramic production a single weapon in the home decoration industry? Why is this?
- JMeter download and installation
- 【机器学习网络】BP神经网络与深度学习-6 深度神经网络(deep neural Networks DNN)
- js三种遍历数组的方法:map、forEach、filter
- 对NIO的初步理解
- JMeter learning notes 004-csv file line number control cycle times
- 第二轮Okaleido Tiger即将登录Binance NFT,或持续创造销售神绩
- Plato farm has a new way of playing, and the arbitrage eplato has secured super high returns
- The new Internet era has come. What new opportunities will Web 3.0 bring us
猜你喜欢

一张图看懂KingbaseES V9

卷积神经网络——灰度图像的卷积

Eureka service registry

tcp协议知识详解

How to set user-defined display for Jiaming Watch

微服务的feign调用header头被丢弃两种解决方案(附源码)

网工知识角|只需四个步骤,教会你使用SecureCRT连接到eNSP,常用工具操作指南必看

centos如何安装mysqldump

Practice of microservice in solving Library Download business problems

How CentOS installs mysqldump
随机推荐
ISG index shows that the it and business service market in the Asia Pacific region fell sharply in the second quarter
Framework learning journey: init process startup process
BigDecimal踩坑总结&最佳实践
js修改对象数组的key值
Wechat input component adds a clear icon, and clicking clear does not take effect
php+swoole
JS modify the key value of the object array
人很话不多,工程师不耍嘴皮子
Preliminary understanding of NiO
匿名命名管道, 共享内存的进程间通信理解与使用
数据分析师岗位分析
356 pages, 140000 words, weak current intelligent system of high-end commercial office complex, 2022 Edition
利用JSON类型在mysql中实现数组功能
Delete the whole line of Excel, and delete the pictures together
ISG指数显示,亚太区IT和商业服务市场在第二季度出现大幅下滑
2022-07-26:以下go语言代码输出什么?A:5;B:hello;C:编译错误;D:运行错误。 package main import ( “fmt“ ) type integer in
spark练习案例(升级版)
Worship the 321 page PDF of the core technology of Internet entrepreneurship that Alibaba is pushing internally. It's really kneeling
Word/Excel 固定表格大小,填写内容时,表格不随单元格内容变化
The new Internet era has come. What new opportunities will Web 3.0 bring us