当前位置:网站首页>DOM events of DOM series
DOM events of DOM series
2022-07-20 11:59:00 【Old__ L】
Catalog
1、 Summary of events
JavaScript It gives us the ability to create dynamic pages , And events can be JavaScript Detected behavior .
Simple understanding : Trigger — Response mechanism .
Every element in a web page can generate something that can trigger JavaScript Events , for example , We can generate a... When the user clicks a button event , And then do something .
2、 Three elements of the event
- Event source ( who ): The element that triggered the event
- Event type ( What event ): for example click Click event
- Event handler ( Zuosa ): The code to execute after the event is triggered ( Function form ), Event handler
2.1、 Example
<body>
<button id="btn"> Tang Bohu </button>
<script> // Click a button , Pop-up dialog box // 1. The event is made up of three parts Event source Event type Event handler We also call it the three elements of an event //(1) Event source The event is triggered by who Button var btn = document.getElementById("btn"); //(2) Event type How to trigger What event For example, mouse click (onclick) Or mouse over Or press the keyboard //(3) Event handler By means of a function assignment complete btn.onclick = function () {
alert(" Some autumn fragrance "); }; </script>
</body>
3、 Steps to execute the event
1、 Get the event source ;
2、 Registration events ( The binding event );
3、 Add event handler ( Take the form of function assignment );
3.1、 Example
<body>
<div>123</div>
<script> // Perform event steps // Click on div Console output I was chosen // 1. Get the event source var div = document.querySelector("div"); // 2. The binding event Registration events // div.onclick // 3. Add event handler div.onclick = function () {
console.log(" I was chosen "); }; </script>
</body>
4、 Common events
4.1、onclick
Click the left mouse button to trigger
4.2、onmouseover
Mouse over trigger
4.3、onmouseout
Mouse off trigger
4.4、onfocus
Get mouse focus trigger
4.5、onblur
Lose mouse focus trigger
4.6、onmousemove
Mouse movement trigger
4.7、onmouseup
Mouse pop up trigger
4.8、onmousedown
Mouse down trigger
Postscript
If you feel the article is not good
//(ㄒoㄒ)//
, Just leave a message in the comments , The author continues to improve ;o_O???
If you think the article is a little useful , You can praise the author ;\\*^o^*//
If you want to progress with the author , Sure Wechat scan QR code , Focus on the front-end old L;~~~///(^v^)\\\~~~
Thank you readers(^_^)∠※
!!!
边栏推荐
- 植物叶片叶绿素测定
- Will there be errors when different IPs execute the same SQL script
- HCIA-R&S自用笔记(12)路由基础、直连路由与静态路由
- 三层交换技术
- 数据库优化方式和问题汇总篇
- 爬虫练习题(二)
- DOM系列之样式属性操作
- Yunna FSU dynamic loop monitoring unit, what is FSU dynamic loop monitoring unit
- PyQt5学习资源准备与环境配置
- Distributed notes (04) - redis of distributed locks (distributed lock implementation, locking process, unlocking process, deadlock prevention, correct and incorrect locking and unlocking Implementatio
猜你喜欢
Soc FPGA搭建工程
Software testing - learning notes 4
爬虫初级知识点(1)
Appium automation test foundation - operating wechat applet
Design and software implementation of FIR digital filter in Digital Signal Processing Experiment III
产品经理必不可少的证书!
流量控制系统pid整定方法仿真
Will there be errors when different IPs execute the same SQL script
DOM系列之元素的属性操作
【NightCafe AI】一分钟创建你想要的NFT数字艺术藏品
随机推荐
opencv(12):cv::rectangle学习与代码演示,使用opencv画矩形/矩形框
ERP capability planning and scheduling
DOM系列之DOM介绍及获取
The Permutation Results by backtracking method (dfs)
1381:城市路(Dijkstra)
iTextSharp快速使用指南
数据库优化方式和问题汇总篇
GameFi 行业下滑但未出局| June Report
五相永磁电机PWM控制系统研究
流量控制系统pid整定方法仿真
MySql索引类型和高性能索引学习总结
Simulation of PID tuning method in flow control system
2022年最新云开发去水印小程序源码
Reptile exercises (III)
直角坐标系旋转
Software testing - learning notes 4
如何找实习工作?怎么准备?
一文搞懂MySQL架构设计,再也不用担心面试官问得太深
Flask请求数据和获取响应
分数阶pid控制和矢量控制永磁电机