js统计

function fixTo(number,i){
 var y = Math.pow(10,i);
 number = number * y;
 number = Math.round(number) / y;
 var x = number.toFixed(i);
 return x;

}


     function setSumById(start){
   var total=0;
   $("[id^='"+start+"']").each(function (){
     if($(this).text()!="")
     total+=parseFloat($(this).text());
    });
      $("#sum_"+start).html(fixTo(total,2));
  }

你可能感兴趣的:(html)