Skip to content
Related Articles

Related Articles

Improve Article
jQuery | position() with Examples
  • Last Updated : 13 Feb, 2019

The position() method is an inbuilt method in jQuery which is used to find the position of the first matched element relative to its parent element in the DOM tree.



Parameters: This method does not contains any parameters.

Return Value: This method returns the position of the first matched element.

Below example illustrate the position() method in jQuery:


<!DOCTYPE html>
       <title>The position Method</title>
      <script src=
      <!-- jQuery code to show the woirking of this method -->
                 var x = $("p").position();
                 alert("Top position: " +;
         div {
             width: 350px;
             height: 100px;
             font-weight: bold;
             font-size: 25px;
             border: 2px solid green;
         <!-- Click on this button  -->
         <button>Click Here!</button>

Before click on the button:

After click on the button:

Related Articles:

My Personal Notes arrow_drop_up
Recommended Articles
Page :