jQuery position() Method

The jQuery position() method can be used to get the position of the first matched element. It finds the position of the element from the top and left corner of the screen.

jQuery position() Method

Syntax

The syntax of this method is given below:-

Get the position of the first matched element
$(selector).position()

The above syntax contains no parameters to use the method.

Example of jQuery position() Method to Get the Position

If you want to find the position of the selected element, you have to use the jQuery position() method. It returns the value of the coordinates from the left side and the top side. You have to specify the position as given in the example below.

Example

Test it Live

Output


This is my paragraph.

When you click the button given above, it displays the position coordinates of the selected element. Check the alert message showing the values of the position of the element.

You may also like to read

I hope you like this tutorial on jQuery position() method. If you have any queries regarding the tutorial, please comment below.

References