js如何获取动态div_right的高度,并赋值给另外一个静态的div_left,让两个div高度一致
【原文求解:js如何获取动态div的高度,并赋值给另外一个静态的divhttp://www.aixincao.com/forum.php?mod=viewthread&t...
【原文
求解:js如何获取动态div的高度,并赋值给另外一个静态的div
http://www.aixincao.com/forum.php?mod=viewthread&tid=3085&fromuid=1
】
js获取div的高度,在主页模板中,有二div,分别是div_left和div_right,由于div_right是内容页是动态变化的,如何让div_right的高度和div_left的高度保持一致,下面是我的JS代码,实现不了效果?如何解决呀。。。。。
<script type="text/javascript" >
function $(id) {
return document.getElementById(id);
}
function allHeight() {
var divs = document.getElementById("div_mid_right");
var divs1 = document.getElementById("div_mid_left");
divs1.scrollHeight = divs.scrollHeight + "px";
alert(divs1.scrollHeight + "px");
alert(divs.scrollHeight + "px");
}
window.onload = allHeight;
</script> 展开
求解:js如何获取动态div的高度,并赋值给另外一个静态的div
http://www.aixincao.com/forum.php?mod=viewthread&tid=3085&fromuid=1
】
js获取div的高度,在主页模板中,有二div,分别是div_left和div_right,由于div_right是内容页是动态变化的,如何让div_right的高度和div_left的高度保持一致,下面是我的JS代码,实现不了效果?如何解决呀。。。。。
<script type="text/javascript" >
function $(id) {
return document.getElementById(id);
}
function allHeight() {
var divs = document.getElementById("div_mid_right");
var divs1 = document.getElementById("div_mid_left");
divs1.scrollHeight = divs.scrollHeight + "px";
alert(divs1.scrollHeight + "px");
alert(divs.scrollHeight + "px");
}
window.onload = allHeight;
</script> 展开
展开全部
有待研究。设置css,固定div_right的高度与left的高度一致就行啊,给div_right加上滚动条就不怕内容变动长度了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<html>
<head>
<script type="text/javascript" >
function $(id) {
return document.getElementById(id);
}
function allHeight() {
var divs = document.getElementById("div_mid_right");
var divs1 = document.getElementById("div_mid_left");
//divs1.scrollHeight = divs.scrollHeight + "px";
divs1.style.height=divs.style.height;
alert(divs1.scrollHeight + "px");
alert(divs.scrollHeight + "px");
}
window.onload = allHeight;
</script>
</head>
<body>
<div id="div_mid_left" style="height:200px;width:100px;float:left;background:red"></div>
<div id="div_mid_right" style="height:10px;width:100px;float:left;background:blue"></div>
</body>
</html>
<head>
<script type="text/javascript" >
function $(id) {
return document.getElementById(id);
}
function allHeight() {
var divs = document.getElementById("div_mid_right");
var divs1 = document.getElementById("div_mid_left");
//divs1.scrollHeight = divs.scrollHeight + "px";
divs1.style.height=divs.style.height;
alert(divs1.scrollHeight + "px");
alert(divs.scrollHeight + "px");
}
window.onload = allHeight;
</script>
</head>
<body>
<div id="div_mid_left" style="height:200px;width:100px;float:left;background:red"></div>
<div id="div_mid_right" style="height:10px;width:100px;float:left;background:blue"></div>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询