Last active
April 3, 2018 18:25
-
-
Save ryanapil/a77df653b73a81b097b4b32fd0fc7d1c to your computer and use it in GitHub Desktop.
jQuery search input through table rows
This file contains 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
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