Javascript - returning concatenates instead of sum of variables from input

前端 未结 6 872
南笙
南笙 2021-01-23 07:12

I am trying to get values from input field using .each() and adding them to show the sum in another input value. But unfortunately in spite of using parseInt() I am

6条回答
  •  攒了一身酷
    2021-01-23 08:16

    If your purpose is this according to your code then it will always sum up with first box value.

      var value = parseInt($(this).val());
        if(value)
        totalvalue = totalvalue + value;
    });
    

    Otherwise you should elaborate your question so that proper answer could be provided.

提交回复
热议问题