I’ve got a simple jQuery $("span.value") which select nodes containing text. This text is guaranteed to be an integer. How do I calculate the sum of all selected node’s text, and place the sum into another node?
<span class="value">3</span>
<span class="value">4</span>
<span class="value">5</span>
<span class="sum">?</span>
You could do this:
I’d suggest using an
idinstead of a class for the sum<span>, even if you’re sure there’s going to be just one. IMO, it’s be less error-prone..