Classification of events in JavaScript
We also all know that there are many kinds of events in JavaScript, and they are also very commonly used. The important thing is that they are not easy to remember. Just read it when writing JavaScript events Once, it was not easy to find when I was looking for it, which was a headache, so let’s classify the events in JavaScript
Mouse click event
mousedown, mousemove, mouseout, dblclick (double-click), contextmenu (right-click menu)
Mouse wheel eventmousewheel
Roller event, suitable for IE /Google safari, DOMMouseScroll–>Firefox’s private scroll wheel event can only be bound using addEventListener().
e.wheelDelta > 0 means the wheel is up. e.wheelDelta < 0 means the wheel is down. e.detail<0 means the scroll wheel is up, e.detail>0 means the scroll wheel is down, privately owned by Firefox.
Keyboard events
keypress, keydown, keyup
keydown can detect all keyboard keys, including physical keys and auxiliary keys [ctrl, shift, alt, f1...]
keypress can only detect physical keys [characters, letters, numbers, symbols, spaces], and can detect the uppercase and lowercase letters, and detect the key you press e.keyCode
Touch screen event
touchstart, trigger when finger presses the screen
touchmove, trigger when finger slides on the screen
touchend, trigger when finger leaves the screen
touchcancel, touch Screen event cancellation
Animation event
Zoom pinchstart zoom gesture starting point
pinchend zoom gesture end point
pinch zoom gesture
pinchin shrink
pinchout zoom
rotate rotateleft rotate left
rotateright rotate right
rotate rotate
swipe swipestart starting point of sliding gesture
swiping sliding
swipeend end point of sliding gesture
swipeleft slide left
swiperight slide right
swipeup slide up
swipedown slide down
swipe slide
drag start dragstart drag the screen
drag drag drag gesture
Drag end dragend drag the screen
Drag drag drag gesture
Long press hold Long press the screen
Tap tap click the screen
Form event
onchange[FormDrop-down listWhen the element changes],
oninput[When the text box is entered]
onsubmit[When the form is submitted]
onfocus[Get focus]
onblur[Lost focus]
Two ways of event binding.
on and addEventListener()
1. On event binding
Events bound through on can be passed and can be set to NULL. Remove.
On events can only be added to the bubbling phase of the event.
2. addEventListener()
Events bound by addEventListener(type, handle, boolean) can be removed by removeEventListener(type, handle, boolean) . boolean is false bound to the bubbling phase of the event. Binds to true to the capture phase of the event.
Event bubbling and capturing
Prevent bubbling:
For events bound by on, use e .cancelBubble = true;
addEventListener Use e.stopPropagation() to prevent event propagation
Block the default event
1, return false;
2, event.preventDefault;
This may not be the most detailed, but these are the most commonly used ones.
The above is the detailed content of Classification of events in JavaScript. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

Classification and Usage Analysis of JSP Comments JSP comments are divided into two types: single-line comments: ending with, only a single line of code can be commented. Multi-line comments: starting with /* and ending with */, you can comment multiple lines of code. Single-line comment example Multi-line comment example/**This is a multi-line comment*Can comment on multiple lines of code*/Usage of JSP comments JSP comments can be used to comment JSP code to make it easier to read

Essential tools for stock analysis: Learn the steps to draw candle charts in PHP and JS. Specific code examples are required. With the rapid development of the Internet and technology, stock trading has become one of the important ways for many investors. Stock analysis is an important part of investor decision-making, and candle charts are widely used in technical analysis. Learning how to draw candle charts using PHP and JS will provide investors with more intuitive information to help them make better decisions. A candlestick chart is a technical chart that displays stock prices in the form of candlesticks. It shows the stock price

With the rapid development of Internet finance, stock investment has become the choice of more and more people. In stock trading, candle charts are a commonly used technical analysis method. It can show the changing trend of stock prices and help investors make more accurate decisions. This article will introduce the development skills of PHP and JS, lead readers to understand how to draw stock candle charts, and provide specific code examples. 1. Understanding Stock Candle Charts Before introducing how to draw stock candle charts, we first need to understand what a candle chart is. Candlestick charts were developed by the Japanese

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

The relationship between js and vue: 1. JS as the cornerstone of Web development; 2. The rise of Vue.js as a front-end framework; 3. The complementary relationship between JS and Vue; 4. The practical application of JS and Vue.

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service
