I want to add some HTML elements that have the same class name.
So, the code will be like this with jQuery.
$(".force").each(function (){
a += parseInt( $(this).html());
});
$("#total_forces").html(a);
In this code, the variable has to be global.
Is there any other elegant way to sum every .force value and get the sum out of the each function without global variable?
ais a global, but I'm hoping that he will clarify if that's the problem, or it's a matter of efficiency, incorrect result, etc.