About javascript event processing and javascript
Event Processing
I. Event Source: any HTML element (node), body, div, And button
Ii. Events: Your operations
Mouse:
Click
Double-click dblick
Oncontextmenu
Copy codeThe Code is as follows:
<Body oncontextmenu = "return false"> // disables 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: <tag on event = "event handler"/>
Instance:
Copy codeThe Code is 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">
Second:
Directly in javascript, the object. on Handler
Copy codeThe Code is as follows:
<Div id = "two">
Hello, helper house http://www.bkjia.com
</Div>
<Script>
Var one = document. getElementById ("two ");
One. onclick = function (){
This. style. backgroundColor = "red ";
}
</Script>
Third:
Almost nobody uses it
Copy codeThe Code is as follows:
<Script for = "event source ID" event = "event"> event handler </script>
<Div id = "th">
Hello, helper house http://www.bkjia.com
</Div>
<Script for = "th" event = "onclick">
Var one = document. getElementById ("th ");
One. style. backgroundColor = "red ";
</Script>
Do you know how to handle javascript events? If you have any questions, leave a message.