About javascript event processing and javascript

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.