Latest web development tutorials

XML DOM removeAttributeNode () method

Element Object Reference Element object

Definition and Usage

removeAttributeNode () method Removes the specified attribute node.

If the default value of the property is defined in the DTD, it will be with the default value when a new property appears.

This function returns the attribute node to be deleted.

grammar

elementNode.removeAttributeNode(node)

参数 描述
node 必需。要删除的节点。


Examples

The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc and delete all <book> element "category" attribute node:

Examples

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('book');

for(i=0;i<x.length;i++)
{
attnode=x.item(i).getAttributeNode("category");
old_att=x.item(i).removeAttributeNode(attnode);
document.write("Removed attribute: " + old_att.name + "
");
}

Output:

Removed attribute: category
Removed attribute: category
Removed attribute: category
Removed attribute: category

try it"

Element Object Reference Element object