You are here: Reference > JavaScript > client-side > style handling > methods > removeProperty

removeProperty method

Browser support:
9
Removes the specified property from the current style object.
Note: The removeProperty method is supported in Internet Explorer from version 9.
In older Internet Explorer versions (and in newer ones as well), the removeAttribute method provides similar functionality.

Syntax:

object.removeProperty (propertyName);
You can find the related objects in the Supported by objects section below.

Parameters:

propertyName
Required. String that specifies the name of the style property to remove. This parameter is not case sensitive.

Return value:

Returns a string that identifies the value of the removed style property. If no property is removed, it returns an empty string in Firefox and Opera, and returns null in Google Chrome and Safari.

Example HTML code 1:

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

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content