Skip to content

Instantly share code, notes, and snippets.

@vaibhav-jain
Created January 24, 2015 15:11
Show Gist options
  • Save vaibhav-jain/3a648885b3a22d53a155 to your computer and use it in GitHub Desktop.
Save vaibhav-jain/3a648885b3a22d53a155 to your computer and use it in GitHub Desktop.
add all numbers in a table column
var sum = 0;
// use querySelector to find all second table cells
var cells = document.querySelectorAll("td:nth-of-type(2)");
for (var i = 0; i < cells.length; i++){
sum+=parseFloat(cells[i].firstChild.data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment