<script type="text/javascript"> function heji(table_id, lie, val_id) { //合计 --xpp //table_id: 要统计的table 的id值 //lie:要统计哪一列 //val_id:将合计值写入哪 totalSou = 0; $("#" + table_id + " tr").each(function () { var num = $($(this).find("td")[lie]).text(); totalSou += getNumValue(num); }); $("#" + val_id).text(Number(totalSou.toFixed(4))); } function getNumValue(num) { if (!isNaN(num)) { num = parseFloat(num); } else { num = 0; } return num; }</script>