JSFiddle - React, Tailwind, and code Playground
HTML
<input type='text' class='get_sum' value= '5:20'/>
<input type='text' class='get_sum' value= '3:10'/>
<input type='text' class='get_sum' value= '2:00'/>
<input type='text' class='get_sum' value= '1:00'/>
<input type='text' class='get_sum' value= '3:50'/>
<br><br>
Total : <input type='text' class='total' />
JavaScript
var t1= ['2:20','3:10','2:00','1:00','3:50'];
var totalh =0;
var totalm =0;
$('.get_sum').each(function() {
if (($(this).val())) {
var h = parseInt(($(this).val()).split(':')[0]);
var m = parseInt(($(this).val()).split(':')[1]);
totalh += h;
totalm += m;
}
});
totalh += Math.floor(totalm / 60);
totalm = totalm % 60;
$('.total').val(totalh.toString() + ':' + totalm.toString())