Learn all about the jQuery function .offset().
.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.
.offset() returns an object containing the properties
Note: jQuery does not support getting the offset coordinates of hidden elements or accounting for borders, margins, or padding set on the body element.
While it is possible to get the coordinates of elements with
display:none is excluded from the rendering tree and thus has a position that is undefined.