THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

HTML DOM click() Method

HTMLElement Object Reference Element Object

Example

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

<input type="checkbox" id="myCheck" onmouseover="myFunction()" onclick="alert('clicked')">

<script>
// On mouse-over, execute myFunction
function myFunction() {
    document.getElementById("myCheck").click(); // Click on the checkbox
}
</script>
Try it yourself »

Definition and Usage

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.


Browser Support

Method
click() Yes Yes Yes Yes Yes

Syntax

HTMLElementObject.click()

Parameters

None

Technical Details

Return Value: No return value

Related Pages

HTML DOM reference: onclick event


HTMLElement Object Reference Element Object