[jQuery] Get "Location" Of A Div

[jQuery] Get "Location" Of A Div


Hey,
What I'm trying to do is create a "popup" that appears below an icon
when you mouseover the icon. To do this I need to get the "location"
of the icon (div) and then I can position the popup accordingly from
there.
The issue that I'm running into is if I don't actually directly assign
the icon an absolute position using CSS, then when I use css("top")
and such, it just returns a value of "auto" rather than an actual
numerical value (pixels). I need to somehow get the "location" (in
pixels from top and left - eg. left: 500px; top: 50px;) of the icon
on the screen. The reason for this being that I can't really add/
subtract pixels to position the popup properly because it isn't giving
me a numerical value to work with. So, is there any way to do this?
For anyone who's wondering, my code currently looks something like
this:
var pixelsFromTop = $("#icon").css("top"); // Value is
"auto"
Any help is greatly appreciated!
P.S. jQuery rocks - I absolutely love it! Oh, and in case anyone was
going to suggest a tooltip plugin: yes, I have heard of the various
ones for jQuery and have tried a wide variety of them yet none can
seem to accomplish what I'm looking for, so I figured I'd work some of
my own magic, or attempt to anyway :)