Reacting to Mouse Events

Learn about the type of mouse events that are occurred by using a mouse.

We'll cover the following

Mouse clicks on any DOM element produce an event of the click type. Tactile interfaces like smartphones and tablets also have click events associated with buttons, which are kicked off by actually pressing a finger on the button.

Mouse event properties

The Event object associated with a click event has a button property which lets you know the mouse button used, as well as clientX and clientY properties that return the horizontal and vertical coordinates of the place where the click happened. These coordinates are defined relative to the page zone currently shown by the browser.

Get hands-on with 1400+ tech skills courses.