jQuery Tutorial Tutorials - jQuery .position() method

jQuery .position() method

The .position() method in jQuery is used to get the coordinates of the matched element,relative to it's parent.

jQuery .position() method Syntax

.position()

.position() method with example

Get the current coordinates of the first matched element.
Return Value: an object containing top and left. {top:xx,left:yy}

example

Get the position of the second paragraph,relative to the offset parent.

var p = $("p:eq(1)");
var position = p.position();
console.log(position);

Try now

Date:2019-08-20 16:07:19 From:www.Lautturi.com author:Lautturi