.position()
と.offset()
の違い
.position()
は指定した要素の親要素との相対距離を取得する.offset()
はdocument
との相対距離を取得するThe .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.