jQuery checkbox and select - sum the values and add in var

前端 未结 6 1111
礼貌的吻别
礼貌的吻别 2020-12-17 07:10

The explanation is below the code:

The code for HTML is :

Add-ons

6条回答
  •  独厮守ぢ
    2020-12-17 07:40

    Here is your answer

    Working Demo

      $('input:checkbox').change(function(){
    var tot=0;
    $('input:checkbox:checked').each(function(){
    tot+=parseInt($(this).val());
    });
     tot+=parseInt($('#more').val());
    $('#usertotal').html(tot)
    });
    
     $('#more').change(function(){
      $('input:checkbox').trigger('change');
     });
    

提交回复
热议问题