Name

button — NN n/a IE 4 DOM n/a

Synopsis

Read-only

Which mouse button was pressed to trigger the mouse event. Although theoretically you should be able to detect the right button, Internet Explorer 4 does not fire mouse events with that button, since context menus always appear in the browser.

Example

if (event.button == 1) {
    handle event for left button
}

Value

Any of the following allowed integers: 0 (no button) | 1 (left button) | 2 (right button) | 4 (middle button of three-button mouse).

Default

0

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.