jQuery position() Method

jQuery position() method sets or returns the current coordinates of the selected elements, relative to the offset parent.

Contrast position() method with offset() method, which retrieves the current position relative to the document.


Here is a syntax for position() method


The position() method does not accept any arguments.


Here, in this example call position() method

<!DOCTYPE html>
  <title>jQuery position() method</title>
  <script src="jquery-latest.min.js"></script>
    $(document).ready(function() {
        var Page = $("p").position();
        $("span").text("Left Position: " + Page.left + ", Top Position: " + Page.top);
  <p>First paragraph star here</p>
  <button>Click here to call position() method</button>
  <br />

Run it...   »