Add button click event handler using onclick event handler - Javascript DOM Event

Javascript examples for DOM Event:onclick

Description

Add button click event handler using onclick event handler

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from   www  .j  a  va  2  s  .  c  o m*/
document.getElementById("test").onclick = Hello;
function Hello(){
    console.log("Hello");
}
    }

      </script> 
   </head> 
   <body> 
      <button type="button" id="test"> Click me! </button>  
   </body>
</html>

Related Tutorials