Skip to content

Instantly share code, notes, and snippets.

@ryanapil
Last active April 3, 2018 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanapil/a77df653b73a81b097b4b32fd0fc7d1c to your computer and use it in GitHub Desktop.
Save ryanapil/a77df653b73a81b097b4b32fd0fc7d1c to your computer and use it in GitHub Desktop.
jQuery search input through table rows
var searchTimeout = 0;
$("input[name='search']").on("keyup paste", function() {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(function() {
var searchValue = $("input[name='search']").val().toLowerCase().trim();
$("table tbody tr").addClass("d-none");
$("table tbody").find("tr").each(function(i) {
if (~$(this).html().toLowerCase().trim().indexOf(searchValue)) {
$(this).removeClass("d-none");
}
});
}, 100);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment