Skip to content

Instantly share code, notes, and snippets.

@kovtunos
Forked from agragregra/jquery-filter-by-field.js
Last active September 29, 2017 14:24
Show Gist options
  • Save kovtunos/cd1402f439285e72d739675eb344f98c to your computer and use it in GitHub Desktop.
Save kovtunos/cd1402f439285e72d739675eb344f98c to your computer and use it in GitHub Desktop.
jQuery Input Field Filter #jquery #form
$('.city-input').keyup(function() {
filter(this);
});
function filter(element) {
var value = $(element).val().toLowerCase();
$('[data-filter]').each(function() {
var $this = $(this),
lower = $this.data('filter').toLowerCase();
if (lower.indexOf(value) > -1) {
$this.show();
} else {
$this.hide();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment