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
What you're parsing line is saying is
Add the
totalValue
to the string from the input, then parse the result.
Which is why it's concatenating. Instead, you need to add the totalValue
outside of the parseInt()
so that it's saying
Take the take the
totalValue
and add the parsed input value to it.
Like this
totalvalue = totalvalue + parseInt($(this).val());
This can be further shortened to
totalvalue += parseInt($(this).val());