Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

clearAttributes

Method of dom/HTMLElementdom/HTMLElement

Syntax

var object = object.clearAttributes();

Return Value

Returns an object of type DOM NodeDOM Node

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Examples

This example uses the clearAttributes method to remove user-defined attributes from an element.

<SCRIPT>
function fnClear(){
   oSource.children[0].clearAttributes();
}
</SCRIPT>
<SPAN ID=oSource>
<DIV
   ID="oDiv"
   ATTRIBUTE1="true"
   ATTRIBUTE2="true"
   onclick="alert('click');"
   onmouseover="this.style.color='#0000FF';"
   onmouseout="this.style.color='#000000';"
>
This is a sample <b>DIV</b> element.
</DIV>
</SPAN>
<INPUT
   TYPE="button"
   VALUE="Clear Attributes"
   onclick="fnClear()"
>

View live example

Notes

Remarks

The clearAttributes method clears only persistent HTML attributes. The ID attribute, styles, and script-only properties are not affected.

Syntax

Standards information

There are no standards that apply here.

Attributions