Simulate a mouse-click when moving the mouse pointer over a checkbox:
Hover over the checkbox to simulate a mouse-click.
<!DOCTYPE html> <html> <body> <form> <input type="checkbox" id="myCheck" onmouseover="myFunction()" onclick="display()"> </form>/* w ww. ja v a 2 s . co m*/ <p id="demo"></p> <script> function display() { document.getElementById("demo").innerHTML = "click event occured"; } function myFunction() { document.getElementById("myCheck").click(); } </script> </body> </html>
The click()
method simulates a mouse-click on an element.
This method can simulate a click on an element.
element.click();