Easy Tutorial
❮ Dom Loadxmldoc Prop Element Lastchild ❯

XML DOM removeAttribute() Method


Definition and Usage

The removeAttribute() method removes the specified attribute.

If the default value of the attribute is defined in the DTD, the new attribute will have that default value when it appears.

Syntax

Parameter Description
name Required. Specifies the attribute to remove.

Example

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc and removes the "category" attribute from all <book> elements:

xmlDoc = loadXMLDoc("books.xml");

x = xmlDoc.getElementsByTagName('book');

document.write(x[0].getAttribute('category'));
document.write("<br>");

x[0].removeAttribute('category');

document.write(x[0].getAttribute('category'));

❮ Dom Loadxmldoc Prop Element Lastchild ❯