Javascript examples for DOM Event:onclick
Add button click event handler using onclick event handler
<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>