有没有办法在做某事之前检查两个或多个身份证件。
例如:
如果选中BOTH复选框1和复选框2,则会发生事件。
但是,如果只有一个或另一个被自己检查,还会发生其他事情。
我以为这会工作,但不是。
function toggleStatus() {
if ($('#checkBox1 #checkBox2').is(':checked')) {
$('.option1 :input').attr('checked',true);
} else {
$('.option1 :input').attr('checked',false);
}
function toggleStatus() {
if ($('#checkBox1').is(':checked')) {
$('.option2 :input').attr('checked',true);
} else {
$('.option2 :input').attr('checked',false);
}
function toggleStatus() {
if ($('#checkBox2').is(':checked')) {
$('.option3 :input').attr('checked',true);
} else {
$('.option3 :input').attr('checked',false);
}
希望我正确地解释。我找了三天,我被卡住了。感谢任何帮助!
解决方法
$('#checkBox1,#checkBox2').change(function() {
if ($('#checkBox1').is(':checked') && $('#checkBox2').is(':checked')) {
// Do some stuff if both Boxes are checked...
}
});