Let’s summarize some simple things
Remarks: The following methods are all wrapped in an EventUtil object, and the method is directly defined using object literals. . .
①Add event method
1 2 3 4 5 6 7 8 9 |
|
②Remove the previously added event method
1 2 3 4 5 6 7 8 9 |
|
③Get events and event object targets
1 2 3 4 5 6 7 8 |
|
④How to prevent compatibility of browser default events
1 2 3 4 5 6 7 |
|
⑤ Compatibility writing method to prevent event bubbling
1 2 3 4 5 6 7 |
|
⑥The mouseover and mouseout events only include methods to obtain related elements
1 2 3 4 5 6 7 8 9 10 11 12 |
|
⑦Mouse wheel judgment
For mousedown and mouseup events, there is a button attribute in the event object,
Represents a button that is pressed or released. The DOM button attribute may have the following three values: 0 represents the main mouse button, 1 represents the middle mouse
button (mouse wheel button), 2 represents the secondary mouse button. In a regular setup, the primary mouse button is the left mouse button, and the secondary mouse button is
The button is the right mouse button.
IE8 and previous versions also provide the button attribute, but the value of this attribute is very different from the button attribute of the DOM.
0: Indicates that the button is not pressed.
1: Indicates the primary mouse button is pressed.
2: Indicates that the mouse button has been pressed.
3: Indicates that the primary and secondary mouse buttons are pressed at the same time.
4: Indicates that the middle mouse button is pressed.
5: Indicates that the main mouse button and the middle mouse button are pressed at the same time.
6: Indicates that the second mouse button and the middle mouse button are pressed at the same time.
7: Indicates three mouse buttons were pressed simultaneously.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
⑧How to obtain the incremental value (delta) of the mouse wheel
1 2 3 4 5 6 7 8 |
|
⑨Get character encoding in a cross-browser way
1 2 3 4 5 6 7 |
|
⑩ Access data in the clipboard
1 2 3 4 |
|
11. Set the data in the clipboard
1 2 3 4 5 6 7 |
|
Encapsulate it and then use it directly.
For complete files and more basic CSS and LESS reset styles, see: https://github.com/LuckyWinty/resetFile
The above is the entire content of this article, I hope it will be helpful to everyone’s study.