Hi, In JavaScript what's the right way to set the scrollHeight of one element to that of another element? Direct assignment has no effect. Thanks, Greg
+1
A:
It's not possible directly. The scrollHeight is a read only property that contain the total height of element content in pixels.
If have element A and you want to have element B with the same scrollHeight as element A, make it so that element B has a single child DIV element (move all previous element B content as child nodes of the DIV) that is set to:
width : 100%;
overflow : hidden;
and using javascript set the height of DIV to scrollHeight of element A (in pixels):
document.getElementById('B').childNodes.item(0).style.height = document.getElementById('A').scrollHeight + 'px';
qbeuek
2009-10-23 19:51:37