Javascript examples for DOM:Element getAttribute
Get element attribute with getAttribute method
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w .ja v a2s. c o m*/ div1 = document.getElementById('div1'); console.log(div1.getAttribute("onclick")); } </script> </head> <body> <div id="div1" onclick="myfun();"> </div> </body> </html>