Home > Web Front-end > JS Tutorial > A brief discussion on javascript event processing_basic knowledge

A brief discussion on javascript event processing_basic knowledge

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:22:16
Original
1077 people have browsed it

Event handling

1. Event source: any HTML element (node), body, div, button

2. Event: your operation

Mouse:
Click Click
dblick Double click
oncontextmenu text menu

Copy code The code is as follows:
//Program that prohibits right-clicking

Put mouseover
mouseout leave
mousedown press
mouseup lift
mousemoveMouse movement
Keyboard:

Keypress Keyboard event
Keyup Lift
Keydown Press

Documentation:

Load Load
onload is an event triggered after the page is loaded
Unload Close
Before unload closes

Form:

focus focus event
                                                    lost focus
Submit Submit event
Change event

Others:

Scroll Scroll
Selectstart select event

3. Event handler

The first type:

Format:
Example:

Copy code The code is as follows:
<script><br> function show(){<br> var one=document.getElementById("one");<br> alert(one.innerText);<br> }<br> show();<br> </script>


wwwwwwwwwwwwwwwww



Second type:

Object.on handler directly in javascript

Copy code The code is as follows:
Hello, Script House
http://www.jb51.net
<script><br> var one=document.getElementById("two");<br> one.onclick=function(){<br> This.style.backgroundColor="red";<br> }<br> </script>


Third type: Basically no one uses it



Hello, Script House
http://www.jb51.net



Have you guys understood the event handling of JavaScript? If you have any questions, please leave me a message.
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template