Bootstrap Filter list

BootstrapWeb DevelopmentCSS Framework

To create a filter list, use the .list-group class in Bootstrap.

You can try to run the following code to create a filter list −

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container">
         <h2>Tutorials</h2>
         <input class="form-control" id="demo" type="text" placeholder="Search here...">
         <br>
         <ul class = "list-group" id = "newList">
            <li class = "list-group-item">Java</li>
            <li class = "list-group-item">jQuery</li>
            <li class = "list-group-item">PHP</li>
            <li class = "list-group-item">AngularJS</li>
            <li class = "list-group-item">Ruby</li>
            <li class = "list-group-item">C</li>
         </ul>
      </div>
      <script>
         $(document).ready(function(){
            $("#demo").on("keyup", function() {
               var value = $(this).val().toLowerCase();
               $("#newList li").filter(function() {
                  $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
               });
            });
         });
      </script>
    </body>
</html>
raja
Updated on 12-Jun-2020 19:45:20

Advertisements