XML DOM removeAttribute() Method
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
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