Reputation: 7568
I am experiencing issues with when setting the height of one DIV based on .clientHeight of another DIV.
Sample of my JS below:
<script>
var height1 = document.getElementById("DIV1").clientHeight;
document.getElementById("DIV2").style.height = height1;
</script>
The weird thing is that when I remove the doctype declaration from the top of the page, the javascript performs the operation correctly (obviously I dont want to remove the doctype from the page...)
Upvotes: 1
Views: 122
Reputation: 7568
Solution:
<script>
var height1 = document.getElementById("DIV1").clientHeight;
document.getElementById("DIV2").style.height = height1 + "px";
</script>
The style.height requires the length not the numeric value.
Hope this helps someone else...
Upvotes: 1