我有一個帶復選框的數據表,我想顯示表數組,但未顯示“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>
如何使用jquery獲取值單元格?
一只斗牛犬
2021-07-10 18:51:06