---
description: https://github.com/codeanddeploy/Jquery-Table-Check-All-Plugin
---

# Multi-table,Multi table (ok)

C:\Users\Administrator\Downloads\Jquery-Table-Check-All-Plugin-master\multi-table.html

<figure><img src="https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1E4Gk2ppVKb4olmnun%2Fuploads%2FFFauxt4SJJLIV3kEN7iA%2FScreenshot_5.png?alt=media&#x26;token=b32500cf-1c59-4de1-98a4-797ea5f36591" alt=""><figcaption></figcaption></figure>

```html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Jquery Table Check All Plugin - codeanddeploy.com</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script type="text/javascript" src="dist/TableCheckAll.js"></script>
  <script type="text/javascript">
  $(document).ready(function() {
    $('#users-table').TableCheckAll({
      checkAllCheckboxClass: '.check-all-users',
      checkboxClass: '.check-user'
    });
    $('#top-websites-table').TableCheckAll();
  });
  </script>
</head>
<body>
  <div class="container mt-5">
    <h3>Users</h3>
    <table class="table table-striped" id="users-table">
      <thead>
        <tr>
          <th scope="col"><input type="checkbox" class="check-all-users"></th>
          <th scope="col">First</th>
          <th scope="col">Last</th>
          <th scope="col">Website</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row"><input type="checkbox" class="check-user"></th>
          <td>Ronard</td>
          <td>Cauba</td>
          <td>https://codeanddeploy.com</td>
        </tr>
        <tr>
          <th scope="row"><input type="checkbox" class="check-user"></th>
          <td>Juan</td>
          <td>Dela Cruz</td>
          <td>https://google.com</td>
        </tr>
        <tr>
          <th scope="row"><input type="checkbox" class="check-user"></th>
          <td>John</td>
          <td>Doe</td>
          <td>https://google.com</td>
        </tr>
      </tbody>
    </table>
    <br>
    <br>
    <br>
    <h3>Top Websites</h3>
    <table class="table table-striped" id="top-websites-table">
      <thead>
        <tr>
          <th scope="col"><input type="checkbox" class="check-all"></th>
          <th scope="col">Name</th>
          <th scope="col">Domain</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row"><input type="checkbox" class="check"></th>
          <td>Google</td>
          <td>https://google.com</td>
        </tr>
        <tr>
          <th scope="row"><input type="checkbox" class="check"></th>
          <td>Youtube</td>
          <td>https://youtube.com</td>
        </tr>
        <tr>
          <th scope="row"><input type="checkbox" class="check"></th>
          <td>Facebook</td>
          <td>https://facebook.com</td>
        </tr>
      </tbody>
    </table>
  </div>
</body>
</html>
```

C:\Users\Administrator\Downloads\Jquery-Table-Check-All-Plugin-master\index.html

```html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Jquery Table Check All Plugin - codeanddeploy.com</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script type="text/javascript" src="dist/TableCheckAll.js"></script>
  <script type="text/javascript">
  $(document).ready(function() {
    $('#users-table').TableCheckAll({
      checkAllCheckboxClass: '.check-all-users',
      checkboxClass: '.check-user'
    });
  });
  </script>
</head>
<body>
  <div class="container mt-5">
    <table class="table table-striped" id="users-table">
      <thead>
        <tr>
          <th scope="col"><input type="checkbox" class="check-all-users"></th>
          <th scope="col">First</th>
          <th scope="col">Last</th>
          <th scope="col">Website</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row"><input type="checkbox" class="check-user"></th>
          <td>Ronard</td>
          <td>Cauba</td>
          <td>https://codeanddeploy.com</td>
        </tr>
        <tr>
          <th scope="row"><input type="checkbox" class="check-user"></th>
          <td>Juan</td>
          <td>Dela Cruz</td>
          <td>https://google.com</td>
        </tr>
        <tr>
          <th scope="row"><input type="checkbox" class="check-user"></th>
          <td>John</td>
          <td>Doe</td>
          <td>https://google.com</td>
        </tr>
      </tbody>
    </table>
  </div>
</body>
</html>
```

C:\Users\Administrator\Downloads\Jquery-Table-Check-All-Plugin-master\default.html

```
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Jquery Table Check All Plugin - codeanddeploy.com</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script type="text/javascript" src="dist/TableCheckAll.js"></script>
  <script type="text/javascript">
  $(document).ready(function() {
    $('#users-table').TableCheckAll();
  });
  </script>
</head>
<body>
  <div class="container mt-5">
    <table class="table table-striped" id="users-table">
      <thead>
        <tr>
          <th scope="col"><input type="checkbox" class="check-all"></th>
          <th scope="col">First</th>
          <th scope="col">Last</th>
          <th scope="col">Website</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row"><input type="checkbox" class="check"></th>
          <td>Ronard</td>
          <td>Cauba</td>
          <td>https://codeanddeploy.com</td>
        </tr>
        <tr>
          <th scope="row"><input type="checkbox" class="check"></th>
          <td>Juan</td>
          <td>Dela Cruz</td>
          <td>https://google.com</td>
        </tr>
        <tr>
          <th scope="row"><input type="checkbox" class="check"></th>
          <td>John</td>
          <td>Doe</td>
          <td>https://google.com</td>
        </tr>
      </tbody>
    </table>
  </div>
</body>
</html>
```

C:\Users\Administrator\Downloads\Jquery-Table-Check-All-Plugin-master\dist\TableCheckAll.js

```
/*! @preserve
 * TableCheckAll.js
 * version: 1.0
 * author: Ronard Cauba <ronard@ecomnuggets.com>
 * license: MIT
 * https://codeanddeploy.com/blog/jquery-plugins/jquery-table-check-all-plugin
 */
$.fn.TableCheckAll = function(options) {
  // Default options
  var settings = $.extend({
    checkAllCheckboxClass: '.check-all',
    checkboxClass: '.check'
  }, options);
  return this.each(function() {
    $(this).find(settings.checkAllCheckboxClass).on('click', function() {
      if ($(this).is(':checked')) {
        $.each($(this).parents("table").find(settings.checkboxClass), function() {
          $(this).prop('checked', true);
        });
      } else {
        $.each($(this).parents("table").find(settings.checkboxClass), function() {
          $(this).prop('checked', false);
        });
      }
    });
    $(this).find(settings.checkboxClass).on('click', function() {
      var totalCheckbox = $(this).parents("table").find(settings.checkboxClass).length;
      var totalChecked = $(this).parents("table").find(settings.checkboxClass + ":checked").length;
      if (totalCheckbox == totalChecked) {
        if (!$(this).parents("table").find(settings.checkAllCheckboxClass).is(':checked')) {
          $(this).parents("table").find(settings.checkAllCheckboxClass).prop('checked', true);
        }
      }
      if (totalCheckbox != totalChecked && !$(this).is(':checked')) {
        $(this).parents("table").find(settings.checkAllCheckboxClass).prop('checked', false);
      }
    });
  });
};
```
