Browse By Name
HTMLCSSJavaScriptAppendix
You are here: Reference > JavaScript > client-side > style handling > methods > removeProperty

removeProperty method

A A Font size Print Content Add new content Share Share
Browser support:
Removes the specified property from the current style object.
In Internet Explorer the removeAttribute method provides similar functionality.
  • To set a value for a style property, use the setAttribute method in Internet Explorer and the setProperty method in Firefox, Opera and Safari.
  • To get the value of a style property, use the getAttribute method in Internet Explorer and the getPropertyValue method in Firefox, Opera and Safari.

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 Safari.

Example HTML code 1:

This example illustrates the use of the removeProperty method:
<head>
    <script>
        function RemoveBGColor (button) {
            if (button.style.removeAttribute) {
                button.style.removeAttribute ("backgroundColor");
            } 
            else {
                button.style.removeProperty ("background-color");
            }
        }
    </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