I have comments/reviews in my page. Every comments has hidden input fields that contains values. What I want to achieve is, to loop through this values (which have classes asigned), and then sum up the values.
<input type="hidden" class="value1" value="20" />
<input type="hidden" class="value2" value="30" />
<input type="hidden" class="value1" value="20" />
<input type="hidden" class="value2" value="30" />
<input type="hidden" class="value1" value="20" />
<input type="hidden" class="value2" value="30" />
Then I have spans, where I want to put out the summed up values like:
<span class="value1sum">60</span>
<span class="value2sum">90</span>
How can I achieve a loop, that loops through the values of both classes (".value1") and (".value2"), sum them up and put the results into the span classes (".value1sum") and (".value2sum")? Thank you very much in advance!
What I can think of is kind of is:
$(".value1").each(function(i, obj) {
//?
});
$("value1sum").html(i);