Javascript examples for DOM:Element attributes
Element attributes Property - Get the name of a <button> element's second (index 1) attribute:
<!DOCTYPE html> <html> <body> <button id="myBtn" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w. j av a2 s. c o m*/ var x = document.getElementById("myBtn").attributes[1].name; document.getElementById("demo").innerHTML = x; } </script> </body> </html>