Basic knowledge about javascript event processing

Source: Internet
Author: User
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:


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.