jQuery根据另一个div的高度动态调整div的大小 [英] Jquery dynamically resize div based on height of another div

查看:478
本文介绍了jQuery根据另一个div的高度动态调整div的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div,最初将其设置为display:none,并使用.slideDown使其可见.它通过ajax加载表. 由于slideDown,包含div的高度增加.我希望另外两个div的高度同时增加.

I have a div that is initially set to display:none, and uses .slideDown to become visible. It loads a table via ajax. Due to the slideDown, the height of the containing div increases. I want the height of two other divs to increase simultaneously.

推荐答案

如果您希望三个div的高度相同;向下滑动后,将css类添加到三个div中,例如同时",

If you want same height for the three divs; Add a css class to three divs like "simultaneously", after slidedown run the below code

var maxHeight = 0;

$('div.simultaneously').each(function(index){
if ($(this).height() > maxHeight)
{
maxHeight = $(this).height();
}
});

$('div.simultaneously').height(maxHeight);

这篇关于jQuery根据另一个div的高度动态调整div的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆