Return the offset coordinates of a <p> element:
The offset() method set or returns the offset coordinates for the selected elements, relative to the document.
When used to return the offset:
This method returns the
offset coordinates of
the FIRST matched element. It returns an object with 2 properties; the top and left positions in pixels.
When used to set the offset:
This method sets the offset
coordinates of ALL matched elements.
Return the offset coordinates:
Set the offset coordinates:
Set offset coordinates using a function:
| Parameter | Description |
|---|---|
| {top:value,left:value} | Required when setting the offset. Specifies the top and left coordinates in pixels. Possible values:
|
| function(index,currentoffset) | Optional. Specifies a function that returns an object containing the top and left
coordinates
|
Set the
offset coordinates
How to set the offset coordinates of an element.
Set
offset coordinates using a function
Using a function to set the offset coordinates of an element.
Set
the offset coordinates for an element using an object
How to set the offset coordinates for an element using a new object.
Set
the offset coordinates for an element using the offset coordinates of another
element
How to set the offset coords for an element using the offset coords of an existing element.
Your message has been sent to W3Schools.