TutorialKart
index.html
►
Run
Reset
<!DOCTYPE html> <html lang="en"> <head> <style> #myElement { border:1px solid #CCC; width:100px; height:100px; } </style> <meta charset="utf-8"> </head> <body> <h2>Get Attributes of HTML Element in JavaScript</h2> <div id="myElement" class="dummy" style="width:100px;height:100px;background:#CCC;">Hello World!</div> <br> <button type="button" onclick="printAttributes()">Click Me</button> <script> function printAttributes(){ var element = document.getElementById("myElement"); var attribs = element.attributes; console.log(attribs); } </script> </body> </html>