I need to have a position relative div plus some some position absolute contents inside it. Now I am trying to dynamically calculate the height of the #one
and then apply it to top of #two
at this demo
but I am getting 20
(it seems it is not calculating the height of the image inside the #one
! can you please let me know why this is happening and how I can prevent it?
$(document).ready(function() { var contentheight = $('#one').height(); console.log(contentheight); $(window).on("resize",function() { var theHeight = $('#one').height(); $("#two").css('top', theHeight +"px"); }); });