Guest User

Untitled

a guest
Jan 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <input id="myInput" type="text" placeholder="Search any keywords">
  2. <button id="mySearchBtn">search</button>
  3. <ul>
  4. <li>Red</li>
  5. <li>Green</li>
  6. <li>Blue</li>
  7. </ul>
  8.  
  9. <input id="myInput" type="text" placeholder="Search any keywords">
  10. <button id="mySearchBtn">search</button>
  11.  
  12. <div class="card-col-wrapper">
  13. <h3>one</h3>
  14. </div>
  15. <div class="card-col-wrapper">
  16. <h3>two</h3>
  17. </div>
  18. <div class="card-col-wrapper">
  19. <h3>three</h3>
  20. </div>
  21.  
  22. <script>
  23.  
  24. $("#mySearchBtn").click(function() {
  25. var value = $('#myInput').val().toLowerCase();
  26. var values = value.split(" ");
  27. var length = values.length
  28. var cards = $(".card-col-wrapper")
  29.  
  30. for (j = 0; j < cards.length; j++){
  31. for (i = 0; i < length; i++){
  32. $(".card-col-wrapper").filter(function() {
  33.  
  34. $(this).toggle($(this).text().toLowerCase().indexOf(values[i]) > -1)
  35. });
  36. }
  37. }
  38. });
  39.  
  40.  
  41. </script>
Add Comment
Please, Sign In to add comment