Hi I need to get position of all element that have attribute "data-branch" per parent - .components
<div class="component">
<ul class="component--list">
<li data-branch="1"><p>item<p></li>
<li><p>item<p></li>
<li>
<p>item<p>
<ul class="component--list">
<li><p>item<p></li>
<li data-branch="2"><p>item<p></li>
</ul>
</li>
<li><p>item<p></li>
<li><p>item<p></li>
</ul>
</div>
I can't use offset() because I have another elements on page with changing hight like expander etc. I must get position only per .components
$('[data-branch="'+ branch.attribute +'"]').each(function(){
var position = $(this).position();
console.log("Top: " + position.top + " Left: " + position.left);
});
Result:
Top: 594.515625 Left: 90
Top: 155.625 Left: 90
Top: 155.625 Left: 90 because position() get position relative to .component--list not to .component :/