我有一個帶有復選框和按鈕驗證的數(shù)據(jù)表(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());
如何讓操作更多更少分裂?
守候你守候我
2021-07-09 14:00:05