I have a html that contains tables like the following example
-
You need to initialize counter with a starting number, otherwise you're performing math on undefined.
var counter = 0;
And then in the loop, use parseInt, parseFloat, or a direct number conversion on the .innerHTML value.
var counter = 0;
for (var i=0; i
In a modern browser, you could do this:
var count = [].reduce.call(valueelements, function(c, v) {
return c + parseFloat(v.innerHTML);
}, 0);
- 热议问题