JavaScript Learning note--6. Event handling

Source: Internet
Author: User

1. Event Source

Any element can be used as the source of the event

2. Events

Mouse class

Click//

Dbclick//Double-click

ContextMenu//Right-click menu

MouseOver//Move in

Mouseout//Move out

MouseDown//Press

MouseUp//Bounce up

MouseMove//Mobile

Selected//select content

Keyboard class

KeyPress//keyboard events (only numbers \ Letters)

KeyUp//Bounce (all keys supported)

KeyDown//press (all keys supported)

Form class

Focus//Get focused

Blur//Lose focus

Submit//Submission

Change//Content changes

Document class

Load//Load complete

Unload//Off

Beforeunload//Before closing

Scroll//page scrolling

3. Event handlers

Add Event

<a onclick= "event handlers" > Processing </a>

<script> object. onclick= "Event handlers" </script>

Let the event not execute

Onclick= "return False"

4. Event Object

Event//Belongs to Window object (ie only supported)

Function (e) {//compatible with FF
var event= e | | window.event;//Resolving Object Compatibility
var keycode= event.charcode | | event.keycode;//Resolving keyboard code compatibility
var eventelement= event.srcelement | | eventtag.target;//Resolving Event Source Compatibility
}

event.srcelement//Event Source

event.keycode//keyboard code \ Occurs when performing keyboard events

Enter 13 left upper right bottom 37 38 39 40

event.clientx//Mouse to the left side of the browser window (to add PX units)

event.clienty//the distance between the mouse and the top of the browser window

event.screenx//Mouse to the left of the screen

event.screeny//Mouse to top of screen

event.cancelbubble//Block Event bubbling (that is, passing up layers)

@zhnoah
Source: http://www.cnblogs.com/zhnoah/
This article is owned by me and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original
The right to pursue legal liability.

JavaScript Learning note--6. Event handling

Related Article

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.