Horje Website
Bs Filters Table Stacked – Bootstrap Filters – Bootstrap Filters – Bootstrap Code

Bs Filters Table Stacked – Bootstrap Filters

Bs Filters Table Stacked - Bootstrap Filters - Bootstrap Filters - Bootstrap Code


 
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Bootstrap Example</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  8. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  9. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
  10. </head>
  11. <body>
  12. <div class="container">
  13. <h2>Filterable Table</h2>
  14. <p>Type something in the input field to search the table for first names, last names or emails:</p>
  15. <input class="form-control" id="myInput" type="text" placeholder="Search..">
  16. <br>
  17. <table class="table table-bordered table-striped">
  18. <thead>
  19. <tr>
  20. <th>Firstname</th>
  21. <th>Lastname</th>
  22. <th>Email</th>
  23. </tr>
  24. </thead>
  25. <tbody id="myTable">
  26. <tr>
  27. <td>John</td>
  28. <td>Doe</td>
  29. <td>[email protected]</td>
  30. </tr>
  31. <tr>
  32. <td>Mary</td>
  33. <td>Moe</td>
  34. <td>[email protected]</td>
  35. </tr>
  36. <tr>
  37. <td>July</td>
  38. <td>Dooley</td>
  39. <td>[email protected]</td>
  40. </tr>
  41. <tr>
  42. <td>Anja</td>
  43. <td>Ravendale</td>
  44. <td>[email protected]</td>
  45. </tr>
  46. </tbody>
  47. </table>
  48. <p>Note that we start the search in tbody, to prevent filtering the table headers.</p>
  49. </div>
  50. <script>
  51. $(document).ready(function(){
  52. $("#myInput").on("keyup", function() {
  53. var value = $(this).val().toLowerCase();
  54. $("#myTable tr").filter(function() {
  55. $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
  56. });
  57. });
  58. });
  59. </script>
  60. </body>
  61. </html>



Try Your Self ->



Published:
October 4, 2020
Author:
admin
Category:
Bootstrap 3, Bootstrap Source Code
Views:
13

This article was posted in Bootstrap 3, Bootstrap Source Code and tagged , , . Bookmark the permalink. Follow comments with the RSS feed for this post.Post a Comment or leave a trackback: Trackback URL.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Horje © 2011 - 2022