开发者

jquery get position from targeted element

how can i get position of an element from targeted element

<div class="photo_container">
     <p>abasdfasdfsadf</p>
       <div id="drag_item" class="box">
      <img src="abc.jpg" id="image_placed" >  
    </div>
</div>

$(function() {
   var p =开发者_如何学编程 $("#image_placed").position('.photo_container');
   alert(p.left);
});


I think what you want is to get the position of the parent .photo_container:

var p = $("#image_placed").closest(".photo_container").position();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜