jQuery Tutorial
jQuery position() Method With Syntax and Example
Understanding position method in jQuery
The position()
method returns the first matched element's position (relative to its parent element). This method returns a pixel-based object with two properties: top and left.
Syntax of position method in jQuery
$(selector).position()
Example of jQuery position method
The top and left positions of a
element are returned:
$("button").click(function(){
var x = $("p").position();
alert("Top: " + x.top + " Left: " + x.left);
});