当前位置:网站首页>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 ).
边栏推荐
- sed输出指定行
- The difference between ArrayList and LinkedList
- Ant JD Sina 10 architects 424 page masterpiece in-depth distributed cache from principle to practice pdf
- scala 不可变Map 、 可变Map 、Map转换为其他数据类型
- 356 pages, 140000 words, weak current intelligent system of high-end commercial office complex, 2022 Edition
- Delete the whole line of Excel, and delete the pictures together
- shel自动设置目录权限
- 微服务的feign调用header头被丢弃两种解决方案(附源码)
- 电商分账系统重要吗,平台应该如何选择分账服务商呢?
- Ribbon load balancing principle and some source codes
猜你喜欢

数据库泰斗王珊:努力创新,精心打磨优质的数据库产品

微服务化解决文库下载业务问题实践

Worship the 321 page PDF of the core technology of Internet entrepreneurship that Alibaba is pushing internally. It's really kneeling

2022 operation of simulated examination question bank and simulated examination platform for safety production management personnel of hazardous chemical production units

【软件工程期末复习】知识点+大题详解(E-R图、数据流图、N-S盒图、状态图、活动图、用例图....)

Okaleido tiger will log in to binance NFT in the second round, or continue to create sales achievements

你了解微信商户分账吗?

卷积神经网络——24位彩色图像的卷积的详细介绍

Nacos startup and login

VR panorama gold rush "careful machine" (Part 1)
随机推荐
JMeter download and installation
452 pages, 130000 words, the overall solution of modern smart Township Xueliang project 2022 Edition
Wechat input component adds a clear icon, and clicking clear does not take effect
sram、dram、sdram、ddr的区别和用途
webpack打包vue项目添加混淆方式,解决缓存问题
数据分析师岗位分析
Cool Lehman VR panorama paves the way for you to start a business
Session&Cookie&token
Is VR panoramic production a single weapon in the home decoration industry? Why is this?
Rust:axum学习笔记(1) hello world
2022 operation of simulated examination question bank and simulated examination platform for safety production management personnel of hazardous chemical production units
Use the kubesphere graphical interface dashboard to enable the Devops function
卷积神经网络——灰度图像的卷积
The real digital retail should have richer connotation and significance
Is VR panorama just needed now? After reading it, you will understand
Using webmvcconfigurer to intercept interface requests is being enhanced (with source code)
els 方块显示原理
Okaleido tiger will log in to binance NFT in the second round, or continue to create sales achievements
Ribbon load balancing strategy and configuration, lazy loading and hungry loading of ribbon
Worship the 321 page PDF of the core technology of Internet entrepreneurship that Alibaba is pushing internally. It's really kneeling