Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM removeAttribute() Method

XML DOM removeAttribute() Method


Element Object Reference Element Object


Definition and Usage

The removeAttribute() method removes the specified attribute.

If the attribute's default value is defined in the DTD, the new attribute will appear with that default value.

Syntax

elementNode.removeAttribute(name)

Parameters Description
name Required. Specifies the attribute to remove.

Example

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

Example

xmlDoc

=

loadXMLDoc

(

"

books.xml

"

)

;

x

=

xmlDoc

.

getElementsByTagName

(

'

book

'

)

;

document

.

write

(

x

[

0

]

.

getAttribute

(

'

category

'

)

)

;

document

.

write

(

"


"

)

;

x

[

0

]

.

removeAttribute

(

'

category

'

)

;

document

.

write

(

x

[

0

]

.

getAttribute

(

'

category

'

)

)

;

Try it »


Element Object Reference Element Object