jQuery calculate sum of values in all text fields

前端 未结 9 1260
渐次进展
渐次进展 2020-11-29 19:52

I have an order form with about 30 text fields that contain numerical values. I\'d like to calculate the sum of all those values on blur.

I know how to select all te

9条回答
  •  囚心锁ツ
    2020-11-29 20:06

    This should fix it:

    var total = 0;   
    $(".price").each( function(){
              total += $(this).val() * 1;
    });
    

提交回复
热议问题