HTML DOM Element Click() Method - W3Schools

HTML DOM Element click() ❮ Previous ❮ Element Object Reference Next

Example

Simulate a mouse-click when moving the mouse pointer over a checkbox:

<input type="checkbox" id="myCheck" onmouseover="myFunction()"; <script> function myFunction() { document.getElementById("myCheck").click(); } </script> Try it Yourself »

Description

The click() method simulates a mouse-click on an element.

This method can be used to execute a click on an element as if the user manually clicked on it.

Related Pages

HTML DOM reference: onclick event

Syntax

element.click()

Parameters

NONE

Return Value

NONE

Browser Support

element.click() is supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes
Previous ❮ Element Object Reference Next +1 Sign in to track progress

Tag » Add Div On Click Javascript