Event handling
One, event Source: Any HTML element (node), body, Div, button
II. Events: your operation
Mouse:
Click
Dblick Double click
OnContextMenu Text Menu
Copy Code code as follows:
<body oncontextmenu= "return false" >//a program that disables the right key
MouseOver, put it on.
Mouseout leave
MouseDown Press the
MouseUp Lift Up
MouseMove Mouse Movement
Keyboard:
KeyPress keyboard Events
KeyUp Lift Up
KeyDown Press the
Document:
Load load
OnLoad is the event that is triggered after a page load completes
Unload off
Before Breforeunload closes
Form:
Focus Event
Blur lose focus
Submit Commit Event
Change events
Other:
Scroll scrolling
Selectstart Select Event
Iii. Event handlers
First type:
Format: <tag on event = "event handler"/>
Instance:
Copy Code code as follows:
<script>
Function Show () {
var One=document.getelementbyid ("one");
alert (One.innertext);
}
Show ();
</script>
<body>
<div id= "One" >
Wwwwwwwwwwwwwwwww
</div>
<input type= "button" onclick= "Show ()" Value= "Show" >
The second type:
Directly inside the JavaScript object. On handler
Copy Code code as follows:
<div id= "Two" >
Hello, cloud-dwelling community http://www.jb51.net
</div>
<script>
var One=document.getelementbyid ("two");
One.onclick=function () {
This.style.backgroundcolor= "Red";
}
</script>
The third type:
Basically no one to use
Copy Code code as follows:
<script for= "event source ID" event= "event" > event handler </script>
<div id= "th" >
Hello, cloud-dwelling community http://www.jb51.net
</div>
<script for= "th" event= "onclick" >
var One=document.getelementbyid ("th");
One.style.backgroundcolor= "Red";
</script>
Small partners understand the JavaScript event processing, if you have any questions, leave me a message.