Home  >  Article  >  Web Front-end  >  Collecting and organizing Event attributes in Javascript_Basic knowledge

Collecting and organizing Event attributes in Javascript_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 17:22:13938browse

altKey, button, cancelBubble, clientX, clientY, ctrlKey, fromElement, keyCode, offsetX, offsetY, propertyName, returnValue, screenX,

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

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

Syntax: event.altKey

Possible values: TRUE when the alt key is pressed, FALSE otherwise. Read only.

2.button Description: Check the pressed mouse button.

Syntax: event.button

Possible values: 0 No button pressed 1 Press the left button 2 Press the right button 3 Press the left button 4 Press the middle button 5 Press the left button and the middle button 6 Press the right button and Middle key 7 Press all keys

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

3.cancelBubble Description: Detect whether to accept the event control of the upper element.

Syntax: event.cancelBubble[ = cancelBubble]

Possible values: This is a readable and writable Boolean value:

TRUE is not controlled by events of the upper element . FALSE allows control by events of upper-level elements. This is the default value.

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

The following is the quoted content:

Copy code The code is as follows: