Change img height based on div height
Hi everyone,
I am trying to create a script that will change the height of an image to a set value depending on the height of a DIV. Basically, the DIV contains a collapsable table and the img is the page's background. I want the background to re-size based on how much of the table is visible. I hope this isn't too confusing.
Here is my script:
Code:
<script type="text/javascript">
function setbgsize() {
var bgimg = document.getElementById('GB');
var tbh = document.getElementById('FAQtable');
if(tbh.style.height = '2816px') {
bgimg.style.height = '1725px';
}
else if(tbh.style.height = '1131px') {
bgimg.style.height = '1025px';
}
else if(tbh.style.height = '803px') {
bgimg.style.height = '825px';
}
else if(tbh.style.height = '639px') {
bgimg.style.height = '500px';
}
else(tbh.style.height = '118px') {
bgimg.style.height = '450px';
}
}
</script>
Cheers,
Oli.