The method of obtaining element dimensions and coordinates in jquery to organize _jquery

Source: Internet
Author: User
first, get the coordinates

1.offset ()

The offset () method returns or sets the offset (position) of the matching element relative to the document. (That is, the viewport coordinates)

The object returned by this method contains two integer attributes: Top and left, in pixels.

This method is valid only for visible elements.

2.position ()

The position () method returns the position (offset) of the matching element relative to the parent element. (relative to the parent element's document coordinates)

The object returned by this method contains two integer attributes: Top and left, in pixels.

This method is valid only for visible elements.

3.offsetParent ()

The offsetparent () method returns the most recent ancestor-positioning element.

The positioning element refers to the element's CSS position property being set to relative, absolute, or fixed elements.

You can set position through JQuery, or through the position properties of CSS.

second, get the size

1.width () and height () methods

The width () method sets or returns the breadth of the element (excluding the inner margin, border, or outer margin).

The height () method sets or returns the elevation of the element (excluding the inner margin, border, or outer margin).

2.innerWidth () and Innerheight () method

The Innerwidth () method returns the width of the element, including the inner margin.

The Innerheight () method returns the height of the element, including the inner margin.

3.outerWidth () and Outerheight () method

The Outerwidth () method returns the width of the element (including the inner margin and border).

The Outerheight () method returns the height of the element (including the inner margin and border).

The Outerwidth (True) method returns the width of the element, including the inner margin, border, and outer margin.

The Outerheight (True) method returns the height of the element, including the inner margin, border, and outer margin.

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.