This article briefly introduces the javascript event processing mechanism, from event sources, event operations to event handlers, and provides some examples.
Event Processing
I. event Source: any HTML element (node), body, p, button
II. events: your operations
Mouse:
Click
Double-click dblick
Oncontextmenu
The code is as follows:
// Prohibit the right-click program
Put mouseover
Mouseout
Mousedown
Mouseup
Mousemove move
Keyboard:
Keypress keyboard events
Keyup lifting
Keydown Press
Documentation:
Load
Onload is an event triggered after page loading is complete.
Unload disabled
Before breforeunload is disabled
Form:
Focus event
Blur loses focus
Submit event
Change event
Others:
Scroll
Selectstart select event
III. event handling procedures
First:
Format:
Instance:
The code is as follows:
Script
Function show (){
Var one = document. getElementById ("one ");
Alert (one. innerText );
}
Show ();
Script
Wwwwwwwwwwwwwwwww
Second:
Directly in javascript, the object. on handler
The code is as follows:
Hello, http://www.jb51.net at the foot of the House
Script
Var one = document. getElementById ("two ");
One. onclick = function (){
This. style. backgroundColor = "red ";
}
Script
Third:
Almost nobody uses it
The code is as follows: