Reputation: 2977
I have some elements positioned via CSS this way:
#myItem{
position: absolute;
left: 50%;
margin-left: -350px;
}
I'd like to get their distance from top and left margin of the page. How can I get those measure with javascript/jquery?
Thanks
Upvotes: 3
Views: 1026
Reputation: 3167
Take a look at jQuery's
and
EDIT: As mentioned by @Nick, .offset() is what you want if you need the position relative to the document
$("#myItem").offset().top;
Upvotes: 6
Reputation: 630349
You can use .offset()
for this:
var offset = $("#myItem").offset();
//use offset.left, offset.top
Upvotes: 5