Element.removeAttribute() (Method)

An accessor method to delete a named custom attribute.


DOM level - 1
JavaScript - 1.5
JScript - 3.0
Internet Explorer - 4.0
Netscape - 6.0
Property/method value type:Boolean primitive
JavaScript syntax:-myElement.removeAttribute(anAttribName)
-myElement.removeAttribute(anAttribName, aCaseSense)
Argument list:aCaseSenseA flag indicating whether lookup is case sensitive or not
anAttribNameAn attribute of an Element object

This is an accessor method which is used to remove named attributes of an Element object. Attributes are not properties in the strict sense of the word but may be accessible as if they were in some implementations. They are gathered together into an Attributes collection which you can access like any other Array or Collection object to retrieve the individual Attribute objects. The accessor methods provide some additional modes of access for convenience.

This accessor is intended to provide a means of managing custom attributes.

If the false value is returned, it may mean that either the attribute did not exist and could not be removed or that the attribute was locked in some way preventing it from being removed. The true value returned by this method indicates the attribute was successfully removed.

Note also that you can only remove attributes that were added with the setAttribute() method. Some attributes may have been added by the browser and may not be removed by scripts.


See also:Attribute object, Attributes object, Element object, Element.getAttribute(), Element.mergeAttributes(), Element.setAttribute()