offset() and position() of jQuery

1. offset()

  • Get the position of the element from the left and top of the document
  • What is obtained is an object, and there are two attributes top and left in the object
$('div').offset()

Two, position ()

  • What is obtained is the position of the element from the positioned parent element
  • The acquisition will get an object, which has two attributes top and left
$('div').position()

Guess you like

Origin blog.csdn.net/qq_52421092/article/details/131259333