get height of a div and set the height of another div using it

javascript

Solution

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';
}

Problem

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> ```

Original source