绝对 .position() 值
Absolute .position() value
有时,当我要求某些对象的.position().top
值时,它不是return绝对值,即如果之前添加了一些图片,.position().top
值是没变。 我怎样才能获取对象的绝对位置(在本例中为 div)?
来自 jquery 文档:
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.
http://api.jquery.com/position/
所以使用.offset()
.
有时,当我要求某些对象的.position().top
值时,它不是return绝对值,即如果之前添加了一些图片,.position().top
值是没变。 我怎样才能获取对象的绝对位置(在本例中为 div)?
来自 jquery 文档:
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.
http://api.jquery.com/position/
所以使用.offset()
.