Javascript examples for DOM:Element addEventListener
Use addEventListener to add event handler to click action
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w ww. j a v a 2 s . c o m*/ document .getElementById('clickme') .addEventListener('click', function() { console.log('attached'); }); } </script> </head> <body> <div onclick="console.log('inline');" id="clickme"> Click me </div> </body> </html>