javascript - calculate the percentage between two numbers inside HTML table TD -
my complete example here in jsfiddle
i have html table few values in it. want find percentage in each tr based on td values in , have append resulted value @ end of each tr.
my jquery code
$('tr').each (function() { var frstcol = $(this).find('.combat').text(); var secol = $(this).find('.ac_yeild').text(); var result = parseint(frstcol) * 100 / parseint(secol); console.log(result); $('.res').text(result); }); how calculate percentage first , second column , put in result column each tr?
use this:
$(this).find('.res').text(result);//this replace specific result class instead of
$('.res').text(result);//this replacing values of res class new value note: getting nan value because of td contain '--' not number.
Comments
Post a Comment