DOM: Remove Element's Attribute Value

By Xah Lee. Date: .

node.removeAttribute(attribute_name) → Remove the attribute. No error if attribute doesn't exist.

The node is a HTML element object.

attribute_name is a string.

Return undefined.

// remove the value of attribute “href” in first link element
const tt = document.getElementsByTagName("a")[0];
tt.removeAttribute("href");

DOM How-To

  1. DOM: Basic DOM Methods
  2. Get Elements by ID, Tag, Name, Class, CSS Selector
  3. Change CSS
  4. Change Node Content
  5. Create/Insert Node
  6. Remove Node
  7. Get Element's Attribute Value
  8. Set Element's Attribute Value
  9. Remove Element's Attribute Value
  10. List/Add/Remove Class Attribute
  11. Add/Remove Event Handler
  12. DOM: Navigate DOM Tree
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS Basics
  4. JS in Depth
  5. JS Reference
  6. DOM
  7. SVG
  8. JS Misc