开发者

How do i get the absolute position of the div?

I want to store the absolute position of my div's. I've made a foreach that targets them all but what function do I use? .posi开发者_开发问答tion() returns relative to parent, but is .offset the right one if I want the absolute position?


With javascript i think you can do like this:

var x = document.getElementById("id").offsetLeft;
var y = document.getElementById("id").offsetTop

And with jQuery you can use offset

Hugs


There are several ways to do this. I would check out these links:

http://api.jquery.com/position/

http://www.quirksmode.org/js/findpos.html


Yes. If you want position relative to the document - API

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜