Created
August 29, 2022 03:27
-
-
Save wibawasuyadnya/92f54bf39a1cce84beb5df2b6c5ca6e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
$("#myInput").on("keyup", function() { | |
var value = $(this).val().toLowerCase(); | |
//Select all article and show | |
$("article > div").show().filter(function() { | |
//Find h3 and p also check if the value is substring of the text. Return true if not found. | |
return $(this).find('h3,p').text().toLowerCase().indexOf(value) === -1; | |
}).hide(); | |
//Hide all h3 and p that that the value is not the substring of text | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment