Collecting Event attributes in Javascript _ basic knowledge

Source: Internet
Author: User
The Event attribute is certainly not unfamiliar to everyone. This article has summarized some common ones. For more information, see altKey, button, cancelBubble, clientX, clientY, and ctrlKey, fromElement, keyCode, offsetX, offsetY, propertyName, returnValue, screenX,

ScreenY, shiftKey, srcElement, srcFilter, toElement, type, x, y

1. altKey Description: checks the status of the alt key.

Syntax: event. altKey

Possible value: When the alt key is pressed, the value is TRUE; otherwise, the value is FALSE. Read-only.

2. button Description: Check the pressed mouse key.

Syntax: event. button

Possible values: 0 No keys, 1 left-click, 2 right-click, 3 right-click, 4 right-click, 5 right-click, and 6 Right-click, and 7 Right-click all keys

This attribute is only used for onmousedown, onmouseup, and onmousemove events. For other events, 0 (such as onclick) is returned regardless of the mouse status ).

3. cancelBubble Description: checks whether the event control of upper-layer elements is accepted.

Syntax: event. cancelBubble [= cancelBubble]

Possible value: This is a read/write Boolean value:

TRUE is not controlled by the event of the parent layer. FALSE allows the event to be controlled by the upper-layer element. This is the default value.

Example: The following code snippet demonstrates that when you click onclick on an image, if the shift key is also pressed at the same time, the upper layer element (body) is canceled) the showSrc () function triggered by the event onclick on.

Reference content is as follows:

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.