Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <input id="myInput" type="text" placeholder="Search any keywords">
- <button id="mySearchBtn">search</button>
- <ul>
- <li>Red</li>
- <li>Green</li>
- <li>Blue</li>
- </ul>
- <input id="myInput" type="text" placeholder="Search any keywords">
- <button id="mySearchBtn">search</button>
- <div class="card-col-wrapper">
- <h3>one</h3>
- </div>
- <div class="card-col-wrapper">
- <h3>two</h3>
- </div>
- <div class="card-col-wrapper">
- <h3>three</h3>
- </div>
- <script>
- $("#mySearchBtn").click(function() {
- var value = $('#myInput').val().toLowerCase();
- var values = value.split(" ");
- var length = values.length
- var cards = $(".card-col-wrapper")
- for (j = 0; j < cards.length; j++){
- for (i = 0; i < length; i++){
- $(".card-col-wrapper").filter(function() {
- $(this).toggle($(this).text().toLowerCase().indexOf(values[i]) > -1)
- });
- }
- }
- });
- </script>
Add Comment
Please, Sign In to add comment