Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML | DOM name Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The DOM name Property is used to return the name of the attribute. It is used for read-only.
Syntax: 
 

attribute.name 

Return Value:This property returns a string value which represent the name of the attribute.
Example: 
 

html




<!DOCTYPE html>
<html>
 
<body>
    <center>
        <h1 style="color:green;">GeeksForGeeks</h1>
        <h2>DOM name Property</h2>
 
        <button onclick="geeks()">Submit</button>
 
        <p id="sudo"></p>
 
 
        <script>
            function geeks() {
                var btn = document.getElementsByTagName("BUTTON")[0];
                var x = btn.attributes[0].name;
                document.getElementById("sudo").innerHTML = x;
            }
        </script>
 
</body>
 
</html>

Output: 

Before click on Button:

 

After click on Button:
 

Supported Browsers: The browser supported by DOM name property are listed below: 
 

  • Apple Safari
  • Google Chrome
  • Firefox
  • Opera
  • Internet Explorer

 

My Personal Notes arrow_drop_up
Last Updated : 23 Jul, 2021
Like Article
Save Article
Similar Reads
Related Tutorials