如何通过jquery维护div的大小?

Bel*_*day 0 javascript css jquery

$('.invoice_resend').hide();
$('.invoice_resend #update_paid').hide(); 
$('.invoice_send').hide();
Run Code Online (Sandbox Code Playgroud)

所以我有这样的代码上面,阶级invoice_resend是一个div,它被点击将被隐藏的按钮时,如上图所示,与#update_paid.invoice_send也将被隐藏,留下我一个" 调整大小DIV "元素.

我想要的是,当隐藏所有其他元素时,.invoice_resend div将保持其高度或需要编辑的任何内容.

编辑:

好的,这是我的整个代码:

if (selected_tab == 0) { //Released tab


$('.invoice_resend').hide();
$('.invoice_send').show();
}
else if ( selected_tab == 1 ) { //Invoiced tab


$('.invoice_resend').show();
$('.invoice_resend #update_paid').show(); 
$('.invoice_send').hide();
}
else if ( selected_tab == 2 ) { //Paid tab


$('.invoice_resend').show();
$('.invoice_resend #update_paid').hide(); 
$('.invoice_send').hide();
}
else if ( selected_tab == 3 ) { //Pending tab


$('.invoice_resend').hide();
$('.invoice_resend #update_paid').hide(); 
$('.invoice_send').hide();
}
Run Code Online (Sandbox Code Playgroud)

似乎css.({visibility: 'hidden' or 'visible'})做了工作但产生了另一个问题.你看,我有几个标签,所以当我点击隐藏所有元素的最后一个标签时,它会变得不稳定,当我点击另一个标签时显示或隐藏随机元素.上面的代码是我的原始代码,我根据你的答案编辑了所有.css.

Sur*_*tta 5

代替 show() hide()

使用css属性

visibility:visible; 

visibility:hidden; 
Run Code Online (Sandbox Code Playgroud)

这里有一个示例演示.

如果你检查,事件元素有它height甚至没有visible.