X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook