jquery obtains the coordinate value of the page element to realize the idea and the Code _jquery

Source: Internet
Author: User
How jquery obtains the coordinates of the page elements Yulutxt is the input box of the input classical quotations, feedbackmessage function See http://www.wesoho.com/article/asp/2765.htm
Copy Code code as follows:

var p = $ ("#yulutxt");
var yuluoffset = P.offset ();
Feedbackmessage (Msg,yuluoffset.left+p.width () +10,yuluoffset.top,5000);

-------------------
1, get the object (custom adjust to open a new Window reference element)
var obj = $ ("#oButton");
The object I get in the instance is the pop-up button, so the new window created will be adjusted by the position of the button, and the bottom right corner of the button will be displayed in the new window that is created in the instance.

2, get the position of the object element (offset () method)
var offset = Obj.offset ();
Gets the position of the object element, which is the top and left of the element, called the Offset.left and the Offset.top, which is the position of the current object at the right and the upper part.

3, gets the object element width (width () method)
var right = Offset.left+obj.width ();
In an instance, gets the position of the lower-right corner of the object and creates the left position of the new window.

4, get the height of the object element (height () method)
var down = Offset.top+obj.height ();
Instance is to get the position of the lower-right corner of the object, creating the top position of the new window

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.