I am trying to make one div use the same height as another.
I am fairly new to javascript and have come up with this to set both heights to be the same.
/* Get height of div within the right column */
var innerheight = $(".innerdiv").height();
/* Get height of left column */
var left = $(".leftcolumn").height();
/* Set height of right column to left on
larger screens else stay same as height as it's child inner div*/
if ($(window).width() > 870) {
$(".rightcolumn").css({ height: leftheight });
}
else
{
$('.rightcolumn').css({ height: innerheight });
}
So I was getting strange results, most of the time it worked fine but occasionally the height would be random.
document.getElementById("height").innerHTML = leftheight;
With this I am getting the same correct value 80% of time but sometimes random values?
What would be causing this? The left column loads images in to it, is there a possible delay loading and it's getting the wrong value? Any way around this?
This question may already have an answer here: How to add onload event to a div element? 16 answers
This isn't what I'm looking for.