Web APIs

Element.removeAttribute()

Try the free JavaScript compiler

Remove an attribute if present; a missing attribute is harmless. Example console output: false.

Formal Syntax & Structure

javascript syntaxjavascript
element.removeAttribute(name)

Parameters & Attributes

NameTypeDescription
namestringAttribute 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"));
JavaScript Reference