English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery position() Method

jQuery HTML/CSS Methods

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

This method returns an object that contains2an object of properties: top and left.

Syntax:

$(selector).position()

Example

Return the top and left position of the paragraph:

$("button").click(function(){
  let p = $("p");
  let position = p.position();
  p.html("left: 	" + position.left + "	top: 	" + position.top);
});
Test and See‹/›

jQuery HTML/CSS Methods