The offset() method is an inbuilt method in jQuery which is used to set or returns the offset coordinates of the selected element.
Parameters: Parameter does not required.
Parameters: The parameter is required when set the offset.
$(selector).offset( function(index, offset) )
Parameters: This method set the offset using function. The parameter used in this method is optional. The index parameter is used to return the position of set element and offset return the coordinate of selected element.
Return Value: This method returns the co-ordinate of matched elements.
Below examples illustrate the offset() method in jQuery:
Example 1: In the code below this will return the co-ordinate of the first matched element.
- What is the difference between position() and offset() in jQuery ?
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jQuery.support Property
- jQuery | jquery Property
- jQuery | prepend() with Examples
- jQuery | dblclick() with Examples
- jQuery | children() with Examples
- jQuery | Hide/Show, Toggle and Fading methods with Examples
- jQuery | focusin() with Examples
- jQuery | Animation, Slide methods with Examples
- jQuery | change() with Examples
- jQuery | filter() with Examples
- jQuery | height() and innerHeight() with Examples
- jQuery | eq() with Examples
- jQuery | empty() with Examples
- jQuery | not() method with Examples
- jQuery | first() with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.