当前位置:网站首页>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>
边栏推荐
- MySQL directory
- Valuenotifier and valuelistenablebuilder in fluent
- Ocx control can be called by IE on some computers, but can not be called by IE on some computers
- Flume learning 1
- Datatabletomodellist entity class
- JWT expiration processing - single token scheme
- Redis docker 主从模式与哨兵sentinel
- 【新书推荐】Deno Web Development
- How to build a private cloud and create a hybrid cloud ecosystem?
- Review the old and know the new
猜你喜欢

About the smart platform solution for business hall Terminal Desktop System

Bloom filter

【JVM】CMS简述

How to reduce the delay in live broadcast in the development of live broadcast source code with goods?

How do databases go to the enterprise cloud? Click to view the answer

机械臂速成小指南(四):机械臂关键部件之减速机

Flume learning III

布隆过滤器

Notes on masking and padding in tensorflow keras

JVM tuning tool commands (notes)
随机推荐
Cobbler Automated Deployment
3. integrate eslint and prettier
How do databases go to the enterprise cloud? Click to view the answer
tf. keras. layers. Attention understanding summary
1, 基本配置
鼠标右键打开cmd(命令行)
Cb/s Architecture - Implementation Based on cef3+mfc
Thrift easy to use
【Ubuntu-redis安装】
单片机 MCU 固件打包脚本软件
事件委托的使用与说明》
How to reduce the delay in live broadcast in the development of live broadcast source code with goods?
Horrible bug records
将小程序容器技术应用到物联网IoT生态建设中
Task summary in NLP
MySQL index optimization miscellaneous
Small program development journey
Redis + MySQL implements the like function
utils 协程
Based on svelte3 X desktop UI component library svelte UI