You are here: Reference > JavaScript > client-side > style handling > properties > length (style, currentStyle, ...)

length property (style, currentStyle, ...)

Browser support:
9
Returns the number of properties that have been set in the current style object.
To get the contents of a style object as a string, use the cssText property.

Syntax:

object.length;
You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Integer that represents the number of properties.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the length property:
<head>
    <script type="text/javascript">
        function GetBodyStyleLength () {
            alert (document.body.style.length);
            alert (document.body.style.cssText);
        }
    </script>
</head>
<body style="color:red; background-color:#e0a0a0;">
    <button onclick="GetBodyStyleLength ();">Get the style length of the body</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

User Contributed Comments

Post Content

Post Content