The jQuery .offset() method allows you to retreive the coordinates of an element relative to its position in the document. The .offset() method also allows you to place the specified element at a certain point on the page by placing the coordinates inside the parentheses.

The .offset() method returns the coordinates of the upper left corner of the bounding box of the element relativer to the upper left corner of the screen. The returned information has the properties of left and top and mus be combined with .left and .top for a readable number, see the example script.

The .position() method is similar to the .offset() method, but returns the coordinates relative to the containing element.

var coords = $("#whereAmI").offset();
var tCoords = ((coords.top).toFixed(0));
var lCoords = ((coords.left).toFixed(0));
$("#result span").html("left: " + lCoords + ", top: " + tCoords);
$("#moveIt").click(function(){
    $("#whereAmI").offset({top:160, left:350});
    var coords = $("#whereAmI").offset();
    var tCoords = ((coords.top).toFixed(0));
    var lCoords = ((coords.left).toFixed(0));
    $("#result span").html("left: " + lCoords + ", top: " + tCoords);
});

The script above assigns the value of the .offset() of the element with id="wherAmI" to the variable coords.

It gets the left coordinates by adding .left and the top coordinates by adding .top. The ().toFixed(0) will remve any information to the right of a decimal point.

<h2 id="whereAmI">Where am I?</h2>
<p id="result">Coords: <span></span></p>
<h4 id="moveIt">Click to move the box to top:160, left:350</h4>

The result is as shown below. Keep in mind that this result box is an iframe, so the top and left are in reference to the top left corner of the iframe, not the monitor screen. Also note that the coordinates are to the upper left corner of th <h2 id="whereAmI"> tags bounding box, so this includes the padding and line-height of the element.