JSFiddle - React, Tailwind, and code Playground
by mohamed taher
HTML
<span class='count'>1</span>
<span class='count'>2</span>
<span class='count'>3</span>
<button id='button'>Go</button>
<hr />
<span>Total: </span><span id='total'></span>
JavaScript
$("#button").click( function(total) {
var newtotal=0,total = 0;
$('.count').each( function() {
var content = $(this).text();
//alert(content);
num = parseInt(content);
// alert(num);
newtotal +=num;
$('#total').html(newtotal);
});
});