How to Implement jquery to obtain the coordinate values of page elements and code

Source: Internet
Author: User

How does jquery get the coordinate value of the page element yulutxt is the input box of the input classic quotes, feedBackMessage function see http://www.wesoho.com/article/asp/2765.htm Copy codeThe Code is as follows: var p = $ ("# yulutxt ");
Var yuluoffset = p. offset ();
FeedBackMessage (msg, yuluoffset. left + p. width () + 10, yuluoffset. top, 5000 );

-------------------
1. Get the object (custom adjustment opens new window reference element)
Var obj = $ ("# oButton ");
The object obtained in the instance is the pop-up window button, so that the position of the created window will be adjusted based on the button, and the lower right corner of the button displayed in the new window will be displayed in the instance.

2. Obtain the position (offset () method) of the object element)
Var offset = obj. offset ();
Obtains the position of an object element, including the top and left of the element. The call method is offset. left and offset. top. The left and top positions of the current object are displayed.

3. Obtain the width () of the object element)
Var right = offset. left + obj. width ();
The instance obtains the position in the lower-right corner of the object and creates the left position of the new window.

4. Obtain the height () method of the object element)
Var down = offset. top + obj. height ();
The instance obtains the position at the bottom right corner of the object and creates the position at the top of the new window.

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.