jQuery offset() Method

The jQuery offset() Method can be used in two ways. The first is to determine the offset coordinates of an element and second change the offset cooridinates.

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

Returning the offset coordinates

The code was taken from the W3C example with selector changed from element to #id

This is a paragraph with the id="para".

Top

Setting the offset

This is a paragraph with the id="para2" - Click to move it.

The new position will be moved to the Links section.

Links

Link to PDF Disabled

If you require a copy please email tempusfugit.me.uk

Top

References -

  • 1 - jQuery offset() Method (Example) - https:// www.w3schools.com/jquery/ tryit.asp?filename= tryjquery_css_offset_object
  • 2 - jQuery Selectors - https://www.w3schools.com/jquery/jquery_selectors.asp