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

如何使用jquery获取值单元格?

如何使用jquery获取值单元格?

一只斗牛犬 2021-07-10 18:51:06
我有一个带复选框的数据表,我想显示表数组,但未显示“PRIME”字段,在我的示例中,我想显示表示 0 的 PRIME 单元格的值,请帮助。这是我的数据表:$(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")) {        items.push({          "nom": r.cells[1].innerText,          "matricule": r.cells[2].innerText,          "adresse": r.cells[3].innerText,          "prime": r.cells[4].innerText        })      }    });    console.log(items);  });})<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><table class="table table-bordered" id="mytable">  <tr>    <th><input type="checkbox" id="check_all"></th>    <th>nom</th>    <th>matricule</th>    <th>adresse</th>    <th>prime</th>  </tr>  <tr>    <td><input type="checkbox" class="checkbox"></td>    <td>najib</td>    <td>52</td>    <td>tihit</td>    <td><input type="text" name="prime" class="form-control" value="0"></td>  </tr>  <tr>    <td><input type="checkbox" class="checkbox"></td>    <td>adil</td>    <td>62</td>    <td>tagmast</td>    <td><input type="text" name="prime" class="form-control" value="0"></td>  </tr>  <tr>    <td><input type="checkbox" class="checkbox"></td>    <td>hajar</td>    <td>72</td>    <td>tizgui</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>
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 256 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信