.position()
methodThe .position()
method in jQuery is used to get the coordinates of the matched element,relative to it's parent.
.position()
method Syntax.position()
.position()
method with exampleGet the current coordinates of the first matched element.
Return Value: an object containing top
and left
. {top:xx,left:yy}
Get the position of the second paragraph,relative to the offset parent.
var p = $("p:eq(1)"); var position = p.position(); console.log(position);