就最佳实践而言,下一个功能(实际上有效)是否不好?
IDE 警告我
'this' 的潜在无效用法。检查 Javascript 'this' 是否在相同的闭包或外部内容中。
$(document).on('change', '#select-all', function(){
    if( this.checked ) {
      $(this).closest('table').find('input[name="row-id"]').each( function() {
        this.checked = true; // Here
      })
    }
    else {
      $(this).closest('table').find('input[name="row-id"]').each( function() {
        this.checked = false; // Here
      });
    }
  });
当我选中一个带有 ID 的复选框时select-all,它会将所有其他复选框标记为已选中。