为了账号安全,请及时绑定邮箱和手机立即绑定

如何让操作更多更少分裂?

如何让操作更多更少分裂?

守候你守候我 2021-07-09 14:00:05
我有一个带有复选框和按钮验证的数据表(matricule、salary、number day 和 premium),我想在单击按钮验证时计算总和值,但有一个错误,它为我提供了这个值的 NaN。<table class="table table-bordered" id="mytable">  <tr>    <th><input type="checkbox" id="check_all"></th>    <th>matricule</th>    <th>salary</th>    <th>number day</th>    <th>premium</th>  </tr>  <tr>    <td><input type="checkbox" class="checkbox"></td>    <td>1</td>    <td>5000</td>    <td>2</td>    <td><input type="text" name="prime" class="form-control" value="0"></td>  </tr>  <tr>    <td><input type="checkbox" class="checkbox"></td>    <td>2</td>    <td>6000</td>    <td>2</td>    <td><input type="text" name="prime" class="form-control" value="0"></td>  </tr>  <tr>    <td><input type="checkbox" class="checkbox"></td>    <td>1</td>    <td>7000</td>    <td>1</td>    <td><input type="text" name="prime" class="form-control" value="0"></td>  </tr></table><div class="form-group col-md-offset-5 ">  <button class="btn btn-success add-all" type="submit" id="hide">Pointage men</button></div>用于检查所有并获取一些值并计算总和的 jQuery 代码:$(document).ready(function() {  $('#check_all').on('click', function(e) {    if ($(this).is(':checked', true)) {      $(".checkbox").prop('checked', true);    } else {      $(".checkbox").prop('checked', false);    }  });  $('.checkbox').on('click', function() {    if ($('.checkbox:checked').length == $('.checkbox').length) {      $('#check_all').prop('checked', true);    } else {      $('#check_all').prop('checked', false);    }  });  // jquery code for display array :  $("#hide").click(function() {    var items = [];    $("tr").each(function(i, r) {      if (i > 0 && $(r).find("input").first().prop("checked")) {        //sum = (((salary/24)*nbre)+premium)        let sum = ((($(r.cells[2]).innerText / 24) * $(r.cells[3]).innerText) + $(r.cells[4]).find('input').val());
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 182 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号