Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
- <script>
- $(document).ready(function(){
- $("#myInput").on("keyup", function() {
- var value = $(this).val().toLowerCase();
- $("#myDIV *").filter(function() {
- $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
- });
- });
- $("#myButton").on("click", function() {
- var value = $(this).val().toLowerCase();
- $("#myDIV *").filter(function() {
- $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
- });
- });
- });
- </script>
- </head>
- <body>
- <h2>Filter Anything</h2>
- <p>Type something in the input field to search for a specific text inside the div element with id="myDIV":</p>
- <input id="myInput" type="text" placeholder="Search..">
- <input id="myButton" type="button" value="Public Safety">
- <div id="myDIV">
- <li>Test 1</li>
- <li>Girl Please</li>
- <li>YO YO YO YO</li>
- <li>Public Safety</li>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement