开发者

jquery get position from targeted element

开发者 https://www.devze.com 2023-03-01 08:14 出处:网络
how can i get position of an element from targeted element <div class=\"photo_container\"> <p>abasdfasdfsadf</p>

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

精彩评论

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