HTML DOM click() Method
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
Element Object