Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.97 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  5. <script>
  6. $(document).ready(function(){
  7.     $("#myInput").on("keyup", function() {
  8.         var value = $(this).val().toLowerCase();
  9.         $("#myDIV *").filter(function() {
  10.             $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
  11.         });
  12.     });
  13.     $("#myButton").on("click", function() {
  14.         var value = $(this).val().toLowerCase();
  15.         $("#myDIV *").filter(function() {
  16.             $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
  17.         });
  18.     });
  19. });
  20. </script>
  21. </head>
  22. <body>
  23.  
  24. <h2>Filter Anything</h2>
  25. <p>Type something in the input field to search for a specific text inside the div element with id="myDIV":</p>
  26. <input id="myInput" type="text" placeholder="Search..">
  27. <input id="myButton" type="button" value="Public Safety">
  28.  
  29. <div id="myDIV">
  30. <li>Test 1</li>
  31. <li>Girl Please</li>
  32. <li>YO YO YO YO</li>
  33. <li>Public Safety</li>
  34. </div>
  35.  
  36. </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement