如何只检查活动选项卡's复选框?它也在检查其他人

How to check only active tab's check boxes? it is checking others also

本文关键字:检查 复选框 其他人 活动 选项      更新时间:2023-09-26

我有5个选项卡,当我选中当前选项卡上的全选复选框时,它也在检查其他选项卡行。请帮帮我。以下代码:

$('.group-checkable').click(function() {
  var $checkboxes = $(':checkbox');
    $checkboxes.prop('checked', $(this).is(':checked'));
});
  $(document).delegate('.deleteAll', 'click', function() { 
    if($('input[name=credential_id]:checkbox:checked').length>0){
      var check = confirm("Do you wish to continue?");
      if(check){ 
      var credential_ids = new Array(); 
      $('input[name=credential_id]:checkbox:checked').each(function(i){      
          credential_ids[i] = $(this).val();
      });
      $.ajax({
          url: 'credentials/delete',
          type: 'GET',
          datatype:'json',
          data: { credential_ids:credential_ids},
          success: function(response) {
            console.log(response);
          },
        });
      } `enter code here`
    }
    else{
      alert("Sorry..No Record Selected..!");
    }   
  });

在这里:

$('.group-checkable').click(function() {                   // when 'group-checkable' is clicked
  var $checkboxes = $(':checkbox');                        //  find ALL checkboxes
    $checkboxes.prop('checked', $(this).is(':checked'));   //   Set their checked attribute
});

您需要调整第2行的选择器,使其更有选择性。