I am trying to do positioning in JavaScript. I am using a cumulative position function based on the classic quirksmode function that sums offsetTop
and o
I have run into this problem when the sibling just to the left of the element is hidden:
<div id="parent">
<div id="element1">some stuff</div>
<div id="element2" style="display: none">some hidden stuff</div>
<div id="element3">child whose offset we want</div>
</div>
I've run into the case where the offsetParent of element3 is null even though element3 itself is visible, and parent is visible.
I've seen thin is Firefox 3.6 and Chrome 5. It seems to also affect the getBoundingClientRect() function on the element3, which is really annoying since that works in so many other cases!