I am simply trying to some how add multiple values, and append the answer in a specified node.
So for example I am trying to add all the values of td.add-hour and output the answer in td.sum-hour
$('td.add-hour').each(function() {
sum += Number($(this).val());
});
$('td.sum-hour').html(sum);
But I’m really struggling to find an simple working solution. Can anyone please advise to a jquery solution.
Please see fiddle below with one of many attempts.
Thanks in advance. Josh
A couple things:
sumis never initialized. Before anything else, write:var sum = 0;.valis to get the value of inputs. You want to use.text().see: http://jsfiddle.net/7Upk7/2/