问题已修改。 对象对象是我的错。使用JQuery获取DIV的高度
我想检测一些div的高度,然后将该值分配给另一个div。
但我写的代码并没有给我一个正确的答案(我对Javascript/Jquery不太好)。
The CSS & HTML仅用于演示目的。
我想给我的.iframe
类留下空间高度,但使用jquery/Javascript。
我的结构几乎相似,并且container
width
是流动的。
$(document).ready(function() {
var lhs = $('.section-updates').parent().outerHeight();
console.log(lhs);
var rhs = $('.customer-focus').parent().height(lhs);
console.log(rhs);
var cfH = $('.customer-focus').outerHeight();
$('.iframe').height(rhs - cfH);
});
.section-updates {
height: 500px;
width: 50%;
background: purple;
float: left;
}
.customer-focus {
height: 200px;
background: yellow;
float: left;
width: 50%;
}
.iframe {
min-height: 100px;
background: tomato;
float: left;
width: 50%;
}
.container {
width: 95%;
height: 100%;
margin: 0 auto;
overflow: hidden;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="container">
<div class="section-updates"></div>
<div class="customer-focus"></div>
<div class="iframe"></div>
</div>
jQuery的'高度(值)'函数返回一个jQuery对象,请参阅[文档](http://api.jquery.com/height/#height2) –
我认为.height()是只读的,因此你的行启动'var rhs'是不合法的。 –
可以多个参数传递给'的console.log(“LHS --------:”,左图);' – Satpal