In JavaScript, an element receives a click when the primary pointer button is pressed and released inside it, when a touch gesture activates it, or when an equivalent action occurs (for example Space / Enter on buttons and links) (MDN). It fires after mousedown and mouseup, in that order.
Register a listener with addEventListener. Check readiness and browser support before you rely on this event.
Syntax
Listen for click. Start with this line.
JavaScript
el.addEventListener("click", fn)
Call
What it does
el.addEventListener("click", fn)
Primary signature.
Built into the browser. Listen with el.addEventListener("click", …) — no import required.
Library declarations
JavaScript
el.addEventListener("click", fn)
Parameters
This member has no parameters beyond those shown in the signature.
Return Value
Return Value
Description
*
Fires as an Element event (listener receives the Event object).
Prefer addEventListener when you need multiple listeners.
Same click event under the hood as Example 2.
Compatibility
Browser Support
Element.click is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
Element click
Primary activation from mouse, touch, keyboard, and assistive tech — after mousedown and mouseup.
WidelyAvailable
Google ChromeFull support · Desktop & Mobile
Full support
Mozilla FirefoxFull support · Desktop & Mobile
Full support
Apple SafariFull support · macOS & iOS
Full support
Microsoft EdgeFull support · Chromium
Full support
OperaFull support · Modern versions
Full support
Internet ExplorerSupported (legacy MouseEvent)
Supported
clickBaseline support
Bottom line: Safe everywhere modern. Prefer real buttons/links for keyboard clicks, and use auxclick for non-primary buttons. See the MDN Element click reference.
Frequently Asked Questions
An element receives click when a pointing-device primary button is pressed and released inside it, when a touch gesture activates it, or when an equivalent action occurs (such as Space or Enter on elements that have a default key handler) (MDN).
No. MDN marks Element click as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. Some parts of the feature may have varying support levels.
A PointerEvent (inherits from MouseEvent). Older specifications used MouseEvent; check compatibility if you rely on PointerEvent-only fields.
click fires after both mousedown and mouseup have fired, in that order (MDN).
For click, detail is the number of consecutive clicks on the target (2 for double-click, 3 for triple-click, and so on). The counter resets after a short idle interval that can vary by browser and user settings (MDN).
Space and Enter click activation applies to elements with a default key event handler (for example buttons and links). Merely adding tabindex does not automatically give every element that keyboard click behavior (MDN).