Bootstrap Filters

Basically there is not any filter facility with only bootstrap script. To make filter able system Other script must use with bootstrap property. Hope you will enjoy this tutorial.

Basic example Filter table

In this example a responsive border is make by using bootstrap classes. While search system is done by using JQuery with bootstrap.

<h3>Filter table</h3>
<div class="container mt-4"> 
  <input class="form-control" id="inputField" type="text" placeholder="Search..">
  <table class="table table-bordered table-hover">
    <thead>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
        <th>Address</th>
      </tr>
    </thead>
    <tbody id="tableBody">
      <tr>
        <td>Farhan</td>
        <td>Ali</td>
        <td>Farhan@example.com</td>
        <td>abc</td>
      </tr>
      <tr>
        <td>Irfan</td>
        <td>Khan</td>
        <td>Irfan@example.com</td>
        <td>def</td>
      </tr>
      <tr>
        <td>Imran</td>
        <td>Hussain</td>
        <td>Imran@example.com</td>
        <td>ghi</td>
      </tr>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
        <td>jkl</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@gmail.com</td>
        <td>mno</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@outlook.com</td>
        <td>pqr</td>
      </tr>
      <tr>
        <td>Anja</td>
        <td>Ravendale</td>
        <td>a_r@gmail.com</td>
        <td>stu</td>
      </tr>
      <tr>
        <td>Ajay</td>
        <td>Devgan</td>
        <td>A_j@gmail.com</td>
        <td>vwx</td>
      </tr>
    </tbody>
  </table>
  <p>Header is not included in search system.</p>
</div>

<script type="text/javascript">
$(document).ready(function(){
  $("#inputField").on("keyup", function() {
    var value = $(this).val().toLowerCase();
    $("#tableBody tr").filter(function() {
      $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
    });
  });
});
</script>

Output of above code

Filter table


Firstname Lastname Email Address
Farhan Ali Farhan@example.com abc
Irfan Khan Irfan@example.com def
Imran Hussain Imran@example.com ghi
John Doe john@example.com jkl
Mary Moe mary@gmail.com mno
July Dooley july@outlook.com pqr
Anja Ravendale a_r@gmail.com stu
Ajay Devgan A_j@gmail.com vwx

Header is not included in search system.








The Best

Comment here

If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.