Description: Get the current coordinates of the first element in the set of matched elements, relative to the offset parent.
version added: 1.2.position()
- This method does not accept any arguments.
.position() method allows us to retrieve the current position of an element (specifically its margin box) relative to the offset parent (specifically its padding box, which excludes margins and borders). Contrast this with
.offset(), which retrieves the current position relative to the document. When positioning a new element near another one and within the same containing DOM element,
.position() is the more useful.
Returns an object containing the properties
Note: jQuery does not support getting the position coordinates of hidden elements or accounting for margins set on the
<html> document element.
The number returned by dimensions-related APIs, including
.position(), may be fractional in some cases. Code should not assume it is an integer. Also, dimensions may be incorrect when the page is zoomed by the user; browsers do not expose an API to detect this condition.
Access the position of the second paragraph: