DOM: Remove Element's Attribute Value

By Xah Lee. Date: . Last updated: .

node.removeAttribute(attribute_name) β†’ Remove the attribute. No error if attribute doesn't exist. Return undefined.

The node is a HTML element object.

attribute_name is a string.

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

DOM How-To


Web Scripting Overview


HTML Input


Web Scripting Examples


Web Scripting Misc


jQuery


node.js

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

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

Web Dev Tutorials