HTML DOM Element click() method

Definition and usage

click() Method simulates mouse click on an element.

This method can be used to perform a click on an element, just like a user manually clicks it.

Example

Simulate clicking the mouse when the mouse pointer is moved over the checkbox:

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

Try it yourself

Syntax

element.click()

Parameter

None.

Return value

None.

Browser support

All browsers support element.click():

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support

Related Pages

HTML DOM Reference Manual:onclick Event