- Offset: Gets the current coordinates of the element relative to the document
- Attention
- Using the offset () method, regardless of how the element is positioned or how its parent element is positioned, is the offset of the element relative to the current viewport.
- Postion: Gets the offset of the element relative to the parent element
- Attention:
- 1, when using the position () method, the fact is that the element is handled with absolute positioning, which is the equivalent of the nearest offset position of the parent element with absolute or relative positioning.
- 2, when using the position () method, if all of its parent elements are in the default positioning (static) mode, they are handled in the same way as offset (), which is the relative offset of the current window.
- Usage: such as var position=$ (this). Position () defines the current element and the current element Css:position:absolute
- Alert (position.top), alert (position.left) outputs the current element distance from the nearest parent element of the vertical distance value and the horizontal distance value note the current element of the father element of the CSS is best for position:relative
The use and difference of the offset and position of JQ