$('.supplier').on('click', function(){
var supplier = $('.supplier').is(":checked");
var customer = $('.customer').is(":checked");
// if both is unchecked, hide the table
if( supplier && customer == false){
alert('hide table');
}
// if supplier is checked, show supplier, else hide supplier
});
如果我不检查.supplier 和.customer,我想隐藏表格
非常感谢你。
最佳答案
目前您的 if 子句如下所示:
if( supplier == true && customer == false){
alert('hide table');
}
您还需要将 supplier
与 false
进行比较,以便您可以使用:
if( supplier == false && customer == false){
alert('hide table');
}
或者:
if( !supplier && !customer){
alert('hide table');
}
而不是:
if( supplier && customer == false){
alert('hide table');
}
关于javascript - 如何检查条件中的两个变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22630128/