JS DOM: Remove Attribute

By Xah Lee. Date: . Last updated: .
node.removeAttribute(AttributeName)
  • Remove the attribute. No error if attribute doesn't exist.
  • Return undefined.

node is a HTML element object.

AttributeName is a string.

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

JS DOM Common Task How-To