You are here: Reference > JavaScript > client-side > style handling > properties > posLeft

posLeft property

Browser support:
Specifies or retrieves the value of the left style property as a floating-point number that specifies the value in the current unit type of the left property.
With the left style property you can set or return the left position of an element with a unit designator as a string. The pixelLeft property specifies or retrieves the left position as an integer, in pixels. If you want to set or retrieve the left position as a floating-point number that specifies the value in the current unit type of the left style property, use the posLeft property.
The properties mentioned above can be used to access style settings. If you need the left position of a rendered element, you can use the offsetLeft property and the getBoundingClientRect method.
The currentStyle.posLeft property is read-only, all others are read/write.

Syntax:

object.posLeft;
You can find the related objects in the Supported by objects section below.

Possible values:

Floating-point number that specifies or retrieves the left position.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the posLeft property:
<head>
    <script type="text/javascript">
        function GetLeftPos (elem) {
            var leftStyle = elem.style.left;
            var leftPx = elem.style.pixelLeft;
            var leftPos = elem.style.posLeft;
            alert ("The left position of the button: " + leftStyle +
                   "\n without unit type: " + leftPos + 
                   "\n in pixels: " + leftPx); 
        }
    </script>
</head>
<body>
    <button style="position:absolute; left:10%; top:40%; width:160px; height:30px;" 
            onclick="GetLeftPos (this);">Get left position!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content