Created
June 4, 2019 22:52
-
-
Save hernandezalek/db7783fa95fca39afcea206789c088b4 to your computer and use it in GitHub Desktop.
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
<div class="grid-container"> | |
<div class="grid-x grid-margin-x margin-vertical-2"> | |
<div class="cell large-12"> | |
<table> | |
<tbody> | |
<tr> | |
<td>Manzanas</td> | |
<td>5</td> | |
</tr> | |
<tr> | |
<td>Pera</td> | |
<td>7</td> | |
</tr> | |
<tr> | |
<td>Uva</td> | |
<td>4</td> | |
</tr> | |
<tr> | |
<td>Total</td> | |
<td id="total"></td> | |
</tr> | |
</tbody> | |
</table> | |
</div> | |
</div> | |
</div> | |
<script> | |
var a = document.querySelectorAll("table > tbody > tr"); | |
var suma = 0; | |
for(var i = 0; i<a.length; i++) { | |
var elem = a[i]; | |
suma += parseInt(elem.querySelector("td:nth-child(2)").textContent); | |
} | |
document.getElementById('total').value = parseInt(suma); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment