我有以下设置:
<div class="row">
<div class="col-xs-6">
<div id="first">
</div>
</div>
<div class="col-xs-6">
<div id="second">
</div>
</div>
</div>
其中,id为first
的div的height
属性设置为auto
。我希望能够自动检测 id 为 first
的 div 的高度变化,并将 id 为 second
的 div 的高度设置为 x-70px
其中 x
是 div first
的高度。
我该怎么做?
最佳答案
使用 jQuery 将第二个 div 的高度设置为第一个 div 的高度。
$("#second").height($("#first").height());
关于jquery - 如何根据其他div高度自动更新div高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38995097/