.position()Возвращает: Object

Описание: Получает значение позиции элемента top и left относительно отступов его родителя.

  • Добавлен в версии: 1.2.position()

    • This method does not accept any arguments.

The .position() method allows us to retrieve the current position of an element relative to the offset parent. 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 top and left.

Note: jQuery does not support getting the position coordinates of hidden elements or accounting for borders, margins, or padding set on the body 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.

Примеры использования