Javascript position two elements on top of each other
<p>I have two divs one above the other. The second on is absolutely positioned below it (an absolute div inside a relative div).</p>

<p>I want to move the second div on top of the other div, so it appears in the middle.</p>

<p>The procedure for this is to set the style.top of DIV2 to be the same as DIV1, this should in theory position it on top of it. However so far attempts have failed.</p>

<p>The absolute positioning is working correctly, because putting in values moves it correctly, but I think I am using the wrong way to get the height/top values of DIV1.</p>

<p>Ideas?</p>

<p>I tried this:</p>

<p>divLoading.style.top = divContent.style.top;</p>

<p>but it stays where it was.</p>

<p>Edit: The problem isn't how absolute/relative works but which javascript values are the correct ones to use. Using DIV2.style.top = DIV2.style.top - DIV1.clientHeight moves it to the top... but clientHeight is not correct, because if DIV1 changes size, it moves DIV2 way too far upwards.</p>

<p>Edit: offsetTop seems to be zero.</p>
