HTML DOM Element click()

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

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.