W3Schools.com

jQuery CSS position() Method

jQuery CSS Methods jQuery CSS Methods

Example

Get the current position of a p element:

$("button").click(function(){
  x=$("p").position();
  alert("Left position: " + x.left + " Top position: " + x.top);
});

Try it yourself »

Definition and Usage

The position() method returns the position of the first selected element, relative to the parent element.

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

Syntax

$(selector).position()


Examples

Try it Yourself - Examples

Get the position of an element inside another element
How to get the position of a p element inside a div element.


jQuery CSS Methods jQuery CSS Methods


WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE