Javascript examples for DOM Event:onclick
Create a function and assign to onclick event handler for button
<html> <head> <title>Example</title> <script type="text/javascript"> function saysomething()//from w ww .j a v a2s. c o m { console.log("I am 29 years old"); } function displayatts() { document.getElementById("buttonone").onclick = saysomething; } </script> </head> <body onload="displayatts();"> <input type="button" id="buttonone" value="me"> </body> </html>