How can I trigger a JavaScript click event?

JavascriptWeb DevelopmentFront End Technology

To trigger a JavaScript click event, let us see the example of mouse hover.

Example

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <p>Hover over the button.</p>
      <form>
         <input type="button" id="test" value="Hover" onmouseover="display()" onclick="alert('click event')">
      </form>
      <script>
         function display() {
            document.getElementById("test").click();
         }
      </script>
   </body>
</html>
raja
Published on 31-Jan-2018 13:46:31
Advertisements