Web APIs
Element.removeAttribute()
Remove an attribute if present; a missing attribute is harmless. Example console output: false.
Formal Syntax & Structure
javascript syntaxjavascript
element.removeAttribute(name)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | string | Attribute to remove. |
Return Value
undefined
No result value.
Working Example
Example Snippetjavascript
const p=document.createElement("p"); p.setAttribute("data-ready",""); p.removeAttribute("data-ready"); console.log(p.hasAttribute("data-ready"));