jquery - do something if each class element has some value -
$("#btn_02").click(function(){ $(".quant").each(function() { var = $(this).html(); alert (a); // each value 0 if (a == 0) {return false;} }); $.ajax({ url: "process02.php", success: function(data) { $("#modalscart").html(data); } }); });
i want stop ajax
code if each .quant
value 0
, , yes, 0
, ajax
code still executed.
so... if of quants 0, want not-execute ajax phone call - right? want execute ajax phone call if amount of 'quants' greater 0.
what start maintain track of total a
, execute $.ajax phone call if a
> 0.
in pseudocode this:
var totala = 0; $(".quant").each { totala += a; } if (totala > 0) { $.ajax(); // ajax phone call here }
jquery ajax
No comments:
Post a Comment