XML DOM removeAttribute()Método


Element 对象参考手册Objeto Element

Definición y uso

El método removeAttribute() elimina el atributo especificado.

Si el valor predeterminado del atributo está definido en el DTD, el nuevo atributo aparecerá con ese valor predeterminado.

Sintaxis

elementNode.removeAttribute(name)

Parámetros Descripción
name Requerido. Especifica el atributo a eliminar.


Ejemplo

El siguiente fragmento de código usaloadXMLDoc()Carga "" en xmlDoc y elimina el atributo "category" de todos los elementos <book>:

Ejemplo

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

Pruébalo »

Element 对象参考手册Objeto Element Otras extensiones