Javascript examples for DOM:Attribute
The name property returns the name of the attribute.
This property is read-only.
A String, representing the name of the attribute
The following code shows how to Get the name of an attribute:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w . java2 s . com var btn = document.getElementsByTagName("BUTTON")[0]; var x = btn.attributes[0].name; document.getElementById("demo").innerHTML = x; } </script> </body> </html>