The Wayback Machine - https://web.archive.org/web/20240204103835/https://www.geeksforgeeks.org/html-dom-click-method/
Open In App
Related Articles

HTML DOM click() Method

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The click() method is used to simulate the mouse click on an element. This method works exactly the same as the element is manually clicked.

Syntax:  

HTMLElementObject.click()

Parameters: No parameters required.

Return Value: No return value.

Example: In this example, when the cursor goes over the radio button, it’ll execute the mouse click event and the radio button is checked as it is clicked manually. 

HTML




<!DOCTYPE html>
<html>
<head>
    <title>
        HTML | DOM click() method
    </title>
    <!--script to stimulate mouse click-->
    <script>
        function click() {
            document.getElementById("input1").click();
        }
    </script>
</head>
 
<body>
    <p>
        Hover over the radio button to simulate
        a mouse-click.
    </p>
    <form>
        <input type="radio" id="input1" onmouseover="click()">
        GeeksforGeeks
    </form>
</body>
</html>


Output: 

 

Supported Browsers: The browser supported by the DOM click() Method are listed below:  

  • Google Chrome 9 and above
  • Edge 12 and above
  • Internet Explorer 5.5 and above
  • Firefox 3 and above
  • Opera 10.5 and above
  • Safari 6 and above

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about!


Last Updated : 09 Jun, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials