我使用以下函数来检查某个条件,以便除非条件为真,否则不会触发颜色框插件!
function settleCashInterface(){
var element;
$('#bill-list').find(".bill-item-list").each(function (){
if($(this).css("display") == "block"){
element = $(this);
return false;
}else{
element = 0;
}
});
if(element != 0){
$(".settle-cash").colorbox({inline:true, width:"72%"});
var data = "billId=" + element.parent().attr("id") + "&settlementType=No";
ajaxCall("/setlement","POST",data,function(response){
$('#settle-cash').find('.table-number').val(response.settleInfo.tableNo);
$('#settle-cash').find('.room').val(element.parent().find('.room-number').html());
$('#settle-cash').find('.num-of-guests').val("3"); //hard coded values
$('#settle-cash').find('.total').val(response.settleInfo.totalAmout);
$('#settle-cash').find('.total-due').val(response.settleInfo.totalAmout);
$('#settle-cash').find('.total-due').prop("disabled", true);
$('#settle-cash').find('.final-value').html(response.settleInfo.totalAmout);
$('#settle-cash').attr("billId",element.parent().attr("id"));
$('#settle-cash').attr("billNo",element.parent().find('.bill-number').html());
});
resetAddBill();
}else{
alert("Select a bill");
}
}
该功能是在点击事件和以下代码上触发!
$('.settle-cash').click(function(){
settleCashInterface();
});
如果显示元素,则颜色框应运行,否则不应运行。当我单击相应的元素时,如果没有具有显示块 css 样式的元素,则会显示一条消息。我用萤火虫调试。当我第一次单击时,条件会完美触发,并且颜色框不会显示!但是当我让一个元素显示并隐藏它时,条件被触发并显示一个警报!当我关闭警报框时,颜色框会被触发!我怎么能阻止这个!