Created
January 24, 2015 15:11
-
-
Save vaibhav-jain/3a648885b3a22d53a155 to your computer and use it in GitHub Desktop.
add all numbers in a table column
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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