offset() in jQuery
Get or Set value of the current coordinates of the first element in the set of matched elements, relative to the document.
offset() returns an object containing the properties of top and left.
Syntax 1 - Get coordinates
$(selector).offset()
Syntax 2 - Set coordinates
$(selector).offset(coordinates)
- coordinates - An object containing the properties of top and left, which are numbers indicating the new top and left coordinates for the elements.
Syntax 3
$(selector).offset(function(index,currentCoordinates))
- index - index position of the element in the set.
- currentCoordinates - object with the new top and left properties.