Javascript examples for DOM HTML Element:Input Button
Calling an alert function from a button but without using onclick
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w .j a v a 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>