Bootstrap Filter list

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 −


Live Demo

<!DOCTYPE html>
      <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>
      <div class = "container">
         <input class="form-control" id="demo" type="text" placeholder="Search here...">
         <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>
            $("#demo").on("keyup", function() {
               var value = $(this).val().toLowerCase();
               $("#newList li").filter(function() {
                  $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)

Updated on: 12-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started