Skip to content

Instantly share code, notes, and snippets.

@rg3915
Forked from olivx/filter_jquery_element.js
Last active January 31, 2019 10:09
Show Gist options
  • Save rg3915/8f395d1e25aef2c3b17396788306acf6 to your computer and use it in GitHub Desktop.
Save rg3915/8f395d1e25aef2c3b17396788306acf6 to your computer and use it in GitHub Desktop.
Filter elements with jQuery - Search (dataTable)
function filter(element, selector) {
var value = $(element).val().toUpperCase();
$(selector +" li").each(function () {
if ($(this).text().toUpperCase().indexOf(value)> -1) {
$(this).show();
} else {
$(this).hide();
}
});
}
$('.search_client_list').keyup(function(){
filter(this, '#list-client');
})
function filter(element, selector) {
var value = $(element).val().toUpperCase();
$(selector +" tr").each(function () {
if ($(this).text().toUpperCase().indexOf(value)> -1) {
$(this).show();
} else {
$(this).hide();
}
});
}
$('.search').keyup(function(){
filter(this, '#table');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment