Javascript examples for DOM:Element addEventListener
Add click event handler to element with addEventListener()
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <button id="myButton" type="button">Submit</button> <script> function addToList() {/* ww w . j a va 2 s . co m*/ console.log("addToList() function called !!!"); } document.getElementById("myButton").addEventListener("click", addToList); </script> </body> </html>