You can use the offset function. It gives you the position of the element relative to (left, top) the document:
var offset = $("#target").offset(); display("span is at " + offset.left + "," + offset.top + " of document");
Real-time example In my browser, this example shows that the range we are aiming at is 157.47 (left, top) of the document. This is due to the fact that I applied a great deal of value to the body element and used a span with a separator above it and some text in front of it.
Here is a second example , showing a paragraph in the upper left corner of the document, showing 0.0 as its position (and also showing the spacing later on that are offset both left and top, 129.19 in my browser).
TJ Crowder Jan 05 2018-11-11T00: 00Z
source share