Javascript-форум (https://javascript.ru/forum/)
-   jQuery (https://javascript.ru/forum/jquery/)
-   -   .offset().left (https://javascript.ru/forum/jquery/49585-offset-left.html)

Nupster 19.08.2014 20:54

.offset().left
 
Почему $('#elem').offset().left и document.getElementById('elem').offsetLeft показывают разные значения?
offsetLeft показывает правильное значение, а .offset().left на 171.5 больше необходимого.
Как сделать так, чтобы .offset().left тоже показывало правильное значение?

Спасибо.

ixth 19.08.2014 21:30

Внимательно читаем доку:

Цитата:

The .offset() method allows us to retrieve the current position of an element relative to the document. Contrast this with .position(), which retrieves the current position relative to the offset parent. When positioning a new element on top of an existing one for global manipulation (in particular, for implementing drag-and-drop), .offset() is more useful.
offsetLeft/Top берется от offset parent.


Часовой пояс GMT +3, время: 05:05.