Reputation: 95
I have a div
that has a relative
position but I need to get the actual absolute
position in that moment. Is that possible?
Upvotes: 0
Views: 31
Reputation: 145458
For JQuery you can use offset
:
var pos = $(element).offset();
console.log("Left: " + pos.left);
console.log("Top: " + pos.top);
DEMO: http://jsfiddle.net/NVVFM/
Upvotes: 0
Reputation: 337714
Use offset()
.
var top = $("#myElement").offset().top;
var left = $("#myElement").offset().left;
Upvotes: 1