当前位置:网站首页>Use and description of event delegation
Use and description of event delegation
2022-06-30 09:56:00 【zimingyo】
Event delegation
summary
- advantage : Add an event to the parent element ( Can improve performance )
- principle : Event delegation is actually the use of Event Bubbling Characteristics , Add an event to the parent element , Child elements can trigger
- Realization : Event object .target You can get the true trigger event element
<body>
<ui>
<li> first </li>
<li> the second </li>
<li> Third </li>
</ui>
<script> let ul=document.queryselect('ul') ul.addEventListener('click',function(e){
console.log(e)// obtain Ul All event objects under console.log(e.target)// Get the currently clicked li Elements console.log(e.target.style.color='red')// Click on the current li, send li The color of the color changes to red }) </script>
</body>
边栏推荐
- Framework program of browser self-service terminal based on IE kernel
- 训练一个图像分类器demo in PyTorch【学习笔记】
- Eight sorts (II)
- 【JVM】G1垃圾回收器简述
- NFS shared services
- Flume learning 4
- Datatabletomodellist entity class
- How to reduce the delay in live broadcast in the development of live broadcast source code with goods?
- Bloom filter
- [Ubuntu redis installation]
猜你喜欢

Differences and relationships among hyper convergence, software defined storage (SDS), distributed storage and server San

NTP of Prometheus monitoring_ exporter

Plan the IT technology route for the new year? Let's learn about Gartner infrastructure hype cycle

Machine learning note 9: prediction model optimization (to prevent under fitting and over fitting problems)

Eight sorts (II)

Read the difference and connection between hyperfusion and private cloud

【Ubuntu-redis安装】

The present situation and challenge of the infrastructure of Yiwen parsing database

JVM notes (III): analysis of JVM object creation and memory allocation mechanism

Rider打开Unity脚本后没有提示
随机推荐
【ARK UI】HarmonyOS ETS的启动页的实现
【JVM】G1垃圾回收器简述
单片机 MCU 固件打包脚本软件
关于字符串的split和join操作
ABAP time function
Flutter的特别之处在哪里
【新书推荐】MongoDB Performance Tuning
将小程序容器技术应用到物联网IoT生态建设中
Pytorch graduate warm LR installation
Abstract classes and interfaces
MCU firmware packaging Script Software
Notes on masking and padding in tensorflow keras
What is the difference between ZigBee, Bluetooth and WiFi (copy and reprint)
Financial private cloud infrastructure scheme evaluation (Architecture and storage)
2021-11-15
utils session&rpc
Shell script multi loop experiment
Comparison problems encountered in recent study
训练一个图像分类器demo in PyTorch【学习笔记】
What makes flutter special