<!的兼容性问题DOCTYPE html>和. clienttheight JavaScript
Compatibility issue with <!DOCTYPE html> and .clientHeight JavaScript
我在设置一个div的高度时遇到了基于另一个div的。clienttheight的问题。
我的JS示例如下:
<script>
var height1 = document.getElementById("DIV1").clientHeight;
document.getElementById("DIV2").style.height = height1;
</script>
奇怪的是,当我从页面顶部删除doctype声明时,javascript执行正确的操作(显然我不想从页面中删除doctype…)
解决方案:
<script>
var height1 = document.getElementById("DIV1").clientHeight;
document.getElementById("DIV2").style.height = height1 + "px";
</script>
风格。高度要求长度,而不是数值。
相关文章:
- 我怎样才能在主干渲染函数之外获得clienttheight值
- document. documentelement . clienttheight和document.body. cli
- clientWidth和clienttheight在Android默认浏览器上延迟
- offsetHeight / clienttheight / scrollHeight永远不会改变
- scrollHeight大于clienttheight,即使没有滚动内容
- 如何获取clientWidth &DIV前的clienttheight是可见的
- 和. clienttheight JavaScript
- clienttheight不能在JavaScript中工作