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 that represents the name of the attribute.
Example: In this example, we are using DOM name Property for the attribute.
HTML
<!DOCTYPE html>
< html >
< head >
< title >
HTML DOM name Property
</ title >
</ head >
< body >
< h1 style = "color:green;" >
GeeksForGeeks
</ h1 >
< h2 >DOM name Property</ h2 >
< button onclick = "geeks()" >
Submit
</ button >
< p id = "sudo" ></ p >
< script >
function geeks() {
let btn =
document.getElementsByTagName("BUTTON")[0];
let x =
btn.attributes[0].name;
document.getElementById("sudo").innerHTML = x;
}
</ script >
</ body >
</ html >
|
Output:

Supported Browsers: The browser supported by DOM name property are listed below:
- Apple Safari
- Google Chrome
- Firefox
- Opera
- Internet Explorer