$('.invoice_resend').hide();
$('.invoice_resend #update_paid').hide();
$('.invoice_send').hide();
所以我上面有这段代码,类 invoice_resend
是一个 div,当单击按钮时它将被隐藏,如上所示,#update_paid
和 .invoice_send
也将被隐藏,给我留下一个“RESIZED 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();
}
似乎 css.({visibility: 'hidden' or 'visible'})
完成了工作但产生了另一个问题。你看,我有几个选项卡,所以当我单击隐藏所有元素的最后一个选项卡时,它会变得不稳定,当我单击另一个选项卡时显示或隐藏随机元素。以上代码是我的原始代码,我根据您的回答将其全部编辑为.css。
最佳答案
代替 show()
hide()
使用CSS属性
visibility:visible;
visibility:hidden;
A sample demo在这里找到。
如果你检查,事件元素有它的 height
甚至 visible
。
关于javascript - 如何通过jquery保持div的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18329495/