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();
精彩评论