You are here: Reference > JavaScript > client-side > style handling > methods > removeAttribute (runtimeStyle, style)

removeAttribute method (runtimeStyle, style)

Browser support:
Removes the specified property from the current style object.
In other browsers, the removeProperty method provides similar functionality.


object.removeAttribute (propertyName [, caseSens]);
You can find the related objects in the Supported by objects section below.


Required. String that specifies the name of the style property to remove. Use the name of the corresponding JavaScript property (camelCase name) instead of the name of the CSS property. The corresponding JavaScript property names can be found on the pages for the CSS properties.
Optional. Integer that specifies the case-sensitivity for the name of the property. This parameter is only supported in Internet Explorer earlier than version 8. The name is not case sensitive since version 8.
In earlier versions, the following values are supported:
The first property with the specified name, regardless of its case, will be removed.
Default. The first property with the specified name, with respect to its case, will be removed.

Return value:

Boolean. One of the following values:
false The property was not removed.
true The property was removed.

Example HTML code 1:

This example illustrates the use of the removeAttribute method:
    <script type="text/javascript">
        function RemoveBGColor (button) {
            if ( {
            else {
    <button onclick="RemoveBGColor (this);" style="background-color:red;">Remove my background color!</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content