XML DOM removeAttribute()Methods


Element object

Definition and Usage

removeAttribute() method removes the specified attribute.

If the default value of an attribute is defined in the DTD, then the new attribute will appear with that default value.

Syntax

elementNode.removeAttribute(name)

Parameter Description
name Required. Specifies the attribute to be deleted.


Example

The following code snippet usesloadXMLDoc()put "books.xmlLoad into xmlDoc and remove the "category" attribute of all <book> elements:

Example

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'));

Try it Yourself »

Element objectother extensions