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 +=
If you don't want to introduce a global variable, you could use something like this:
$("#total_forces").html(function() { var a = 0; $(".force").each(function() { a += parseInt($(this).html()); }); return a; });