Tutorials References Exercises Videos Menu
Free Website Get Certified Upgrade

jQuery position() Method

❮ jQuery HTML/CSS Methods


Return the top and left position of a <p> element:

  var x = $("p").position();
  alert("Top: " + x.top + " Left: " + x.left);
Try it Yourself »

Definition and Usage

The position() method returns the position (relative to its parent element) of the first matched element.

This method returns an object with 2 properties; the top and left positions in pixels.



Try it Yourself - Examples

Return the position of an element relative to its parent element
How to get the position of a <p> element inside a <div> element.

❮ jQuery HTML/CSS Methods