我为此尝试了很多东西,但似乎无法让它按预期工作。它要么一直显示确认对话框,要么根本不显示。如果在单击“下一步”按钮(“#step0Next”)时没有选中它们,我有10个带“ex”类的复选框。我希望它显示一个确认对话框。
$("#step0Next").live('click', function(event) {
$('#step1Prev').click(); //go back to step 1
if($('.ex').is(":not(:checked)")) { //my conditions for popping confirm dialog
if(!confirm("You have not selected an exchange(s). If you continue, all streaming market data will be delayed by ten minutes excluding market metrics which will be real time. Press'OK' to continue or 'Cancel' to add an exchange(s).")) return; //user clicks OK
$('#step0Next').die('click');
}
$(this).triggerHandler('click'); //make #step0Next behave as usual after clicking OK
});
答案 0 :(得分:2)
试试这个
$('.ex:checked').length == 0
答案 1 :(得分:1)
你的功能一般看起来有点复杂。您可以在“支票”检查中找到一个可以简化的地方:
if($(".ex:checked").length == 0){ /* do confirm here*/}