Nick
Nick

Reputation: 6025

offsetParent temporarily disappears

RDC70 is the offset parent of RP70. At one point in the code, however, this is not the case. The following returns null:

console.log($('#RP70').get(0).offsetParent);

[Note: This is edited from the original post.]

Soon after, however, it gives:

<div id="RDC70" class="rdc" style="display: block;">

At both points, however, console.log($('#RCD70')); returns [div#RCD70.rcd]

So... I have two questions: (1) What jQuery can I use to investigate RDC70 while the offsetParent relationship is broken? (2) Why might this be happening?

Thanks.

Upvotes: 0

Views: 243

Answers (1)

jholloman
jholloman

Reputation: 1979

Two things could be happening. It seems most likely that the elements have not yet loaded into the DOM when you're calling the code that generates the "null" outputs.

From the Mozilla Developer Network: offsetParent returns null when the element has style.display set to "none". https://developer.mozilla.org/en/DOM/element.offsetParent

The offsetParent is not likely set to display: none though since it itself is returning null.

Upvotes: 2

Related Questions