表格列合计

  1. <table class="table table-border table-bordered table-hover table-bg" id="mytable">
  2. <thead>
  3. <tr>
  4. <th scope="col" colspan="6">用户统计列表</th>
  5. </tr>
  6. <tr class="text-c">
  7. <th width="10">编号</th>
  8. <th width="30">用户名</th>
  9. <th width="20">存款</th>
  10. <th width="20">下注</th>
  11. <th width="20">中奖</th>
  12. </tr>
  13. </thead>
  14. <tbody>
  15. {volist name="data" id="vo"}
  16. <tr style="text-align: center">
  17. <td>{$vo.id}</td>
  18. <td>{$vo.nickname}</td>
  19. <td>{$vo.coin}</td>
  20. <td>{$vo.coin}</td>
  21. </tr>
  22. {/volist}
  23. {$quick ? $quick : ''}
  24. </tbody>
  25. <tr id="totalRow"></tr>
  26. </table>
  27. <tr>
  28. <td>所有用户总计</td>
  29. <td></td>
  30. <td></td>
  31. <td>{$sum_coin}</td>
  32. </tr>

js:

  1. <script>
  2. $(document).ready(function() {
  3. var totalRow = 0;
  4. $('#mytable tr').each(function() {
  5. $(this).find('td:eq(2)').each(function(){
  6. totalRow += parseFloat($(this).text());
  7. });
  8. });
  9. $('#totalRow').append('<td>当前页合计</td><td></td><td>'+totalRow.toFixed(2)+'</td>');
  10. });
  11. </script>
相关评论(0)
您是不是忘了说点什么?

友情提示:垃圾评论一律封号...

还没有评论,快来抢沙发吧!