Web APIs
Element.getAttribute()
getAttribute reads an attribute string or null. DOM properties may reflect attributes with a different type. Boolean attributes are true by presence, not by the spelling of their value.
Formal Syntax & Structure
javascript syntaxjavascript
element.getAttribute(qualifiedName)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| qualifiedName | string | Attribute name. |
Return Value
string | null
Attribute value or null.
Working Example
Example Snippetjavascript
const b=document.createElement("button");b.setAttribute("disabled","false");console.log(b.disabled,b.getAttribute("disabled"));