Jquery

jQuery Intro

jQuery Intro Quiz

jQuery Intro Exercise

jQuery Basic

jQuery Basic Quiz

jQuery Basic Exercise

jQuery Advance

jQuery Advance Quiz

jQuery Advance Exercise

jQuery Selectors

jQuery Effects

jQuery Events

jQuery Methods and Properties

jQuery Traversing

jQuery CSS and HTML Methods

jQuery offset() Method

jQuery offset() Method

 

 

The offset() method is used to set or return the offset coordinates for the selected elements, relative to the document.

 

For your Information:-

 

When it is used to return the offset coordinates of the FIRST matched element. It will return an object with 2 properties i.e, the top and left positions in pixels.
When it is used to sets the offset coordinates, it will set for ALL matched elements.

 

Syntax:-

 

  1. Its syntax for returning offset coordinates is:- $(selector).offset()
  2. Its syntax for setting offset coordinates is:- $(selector).offset({top:value,left:value})
  3. Its syntax for setting coordinates with function is:- $(selector).offset(function(index,currentoffset))

 

Further Explanation:-

 

Parameter Description
{top:value,left:value} Required when setting the offset. Specifies the top and left coordinates in pixels.
function(index,currentoffset) Optional. Specifies a function that returns an object containing the top and left coordinates
  • index - Returns the index position of the element in the set
  • currentoffset - Returns the current coordinates of the selected element

Code Explanation

All Tutorials related to jQuery CSS and HTML Methods

All Sections related to Jquery