Button to fire the click event automatically - Javascript DOM Event

Javascript examples for DOM Event:click

Description

Button to fire the click event automatically

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
function haha1()//from  w  ww .  ja  v  a 2  s.  com
{
    console.log('haha1');
}

      </script> 
      <script>
  window.onload = function(){
    document.getElementById('haha').onclick = function(){
       haha1();
    };
   document.getElementById('haha').click();
  }

      </script> 
   </head> 
   <body> 
      <input type="button" id="haha" value="lol">  
   </body>
</html>

Related Tutorials