Talk about JavaScript events

Source: Internet
Author: User

JavaScript events
1. Click event onclick
Obtn.click=function () {};
2. Move-in/move-out event Onmouseover/onmouseout Note: This event is also triggered when you move in and out of the parent and into the child.
Obtn.mouseover=function () {}
3. Mouse Press/Lift Onmousedown/onmouseup
Obtn.onmousedown=function () {}
3. Move-in/move-out event Onmouseenter/onmouseleave Note: Moving in and out of the parent, entering the child, does not trigger this event
Obtn.mouseleave=function () {}
4. Get/Lose Focus Onfocus/onblur
Obtn.onfocus=function () {}
5. Keyboard events Press/Lift onkeydown/onkeypress
Obtn.onkeydown=function (event) {
var Num=event.keycode;
};
Note: The value of the Event.keycode
9 tab
Enter
20 CAPS Lock
32 Space Key
37 left
38 on
39 Right
40 down
6. Bind Event/Unbind
Google Firefox Obtn.addeventlistener ("event", "Callback function", false);
Obtn.removeeventlistener ("Event", "Callback function", false);
Note: False only listens for events that are bubbling
IE9 obtn.attachevent ("event", "callback function");
Obtn.detachevent ("Event", "callback function");
7. Roller event Onmousewheel/dommousescroll (Firefox)

8. Block Bubbling Events
Event.stoppropagation () block event bubbling non ie
Return False;ie
8. Block Default Events
Event.preventdefault () block default events non IE
Return False;ie

Cond.....

Talk about JavaScript events

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.