Javascript examples for DOM:Attribute
Attribute item() Method - Use attributes[index] to get attribute
<!DOCTYPE html> <html> <head> <style> .example {/*from w ww. ja v a 2 s .com*/ color: red; padding: 10px; width: 150px; font-size: 15px; } </style> </head> <body> <button onclick="myFunction()" class="example">Test</button> <p id="demo"></p> <script> function myFunction() { var a = document.getElementsByTagName("BUTTON")[0]; var x = a.attributes[1].name; document.getElementById("demo").innerHTML = x; } </script> </body> </html>