Latest web development tutorials
 

HTML DOM name Propery

< Attribute Object

Example

Get the name of an attribute:

var x = document.getElementsByTagName("BUTTON")[0].attributes[0].name;

The result of x will be:

onclick
Try it Yourself »

Definition and Usage

The name property returns the name of the attribute.

This property is read-only.

Tip: You can use the attr.value property to get the value of an attribute.


Browser Support

Property
name Yes Yes Yes Yes Yes

Syntax

attribute.name

Technical Details

Return Value: A String, representing the name of the attribute
DOM Version Core Level 1

< Attribute Object