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: