How to get offset() relative to parent in jQuery?

前端 未结 4 865
无人共我
无人共我 2020-12-25 09:37

This gives me the position of some element from the left edge of the main window:

$(\'#bar\').offset().left;

If that element is situated in

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-25 10:25

    offsetLeft = $('#bar').position().left;
    offsetTop = $('#bar').position().top;
    

提交回复
热议问题