Left, pixelLeft, posLeft, and offsetLeft in JS

Source: Internet
Author: User
Left (string, indicating the & amp; 20540; of left in html) usage: 1. alert (documentgetElementById (& 039; divid & 039;) styleleft) if no value is set, the system returns NULL 2, documentgetElementById (& 039; divid & 039;) styleleft & 039; 100 p left (string, that is, the value of left in html .)
Usage:
1. alert (document. getElementById ('divid'). style. left) // if no value is set, null is returned.
2. document. getElementById ('divid'). style. left = '100px '; // note that the unit is attached.


PixelLeft (numeric type, which converts the left value (0 if it is an empty string) to a pixel value (excluding unit ))
Usage:
1. alert (document. getElementById ('divid'). style. pixelLeft)
2. document. getElementById ('divid'). style. pixelLeft = 100; // This attribute only supports IE


PosLeft (floating point type, which converts the left value (0 if it is an empty string) to a value (without unit ))
Usage:
1. alert (document. getElementById ('divid'). style. posLeft)
2. document. getElementById ('divid'). style. posLeft = 100; // This attribute only supports IE


OffsetLeft (the offset of an element relative to its parent element. If no parent element is located, it is relative to the page .)
Usage:
1. alert (document. getElementById ('divid'). offsetLeft) // return a value


Jquery1.2 and later support: $ ("# divid"). offset (). left
Usage:
1. alert ($ ("# divid"). offset (). left)
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.