Skip to content

Instantly share code, notes, and snippets.

@wibawasuyadnya
Created August 29, 2022 03:27
Show Gist options
  • Save wibawasuyadnya/92f54bf39a1cce84beb5df2b6c5ca6e1 to your computer and use it in GitHub Desktop.
Save wibawasuyadnya/92f54bf39a1cce84beb5df2b6c5ca6e1 to your computer and use it in GitHub Desktop.
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