I have two divs, neither have a height set in css, as I want to take whatever height they end up as and set the other div to be that height.
The javascript I have is this
function fixHeight() {
var divh = document.getElementById('prCol1').height;
document.getElementById('prCol1').innerHTML = '<ul><li>' + divh + '</li></ul>';
document.getElementById('prCol2').style.height = divh + 'px';
}
I have the following line of code just to see if I am getting some kind of actual response.
document.getElementById('prCol1').innerHTML = '<ul><li>' + divh + '</li></ul>';
I have a onload set to run the function
my two divs look like this
<div id="prCol1">
..content..
</div>
<div id="prCol2" class="slideshow">
..content..
</div>
Use offsetHeight
- http://jsfiddle.net/HwATE/
function fixHeight() {
var divh = document.getElementById('prCol1').offsetHeight; /* change this */
document.getElementById('prCol1').innerHTML = '<ul><li>' + divh + '</li></ul>';
document.getElementById('prCol2').style.height = divh + 'px';
}
You can use jQuery to get the height and set it.
var h = $("#prCol1").height();
$("#prCol2").height(h);
you can get height by this code:
document.getElementById('YourElementID').clientHeight;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With