Skip to content

Instantly share code, notes, and snippets.

@agragregra
Last active April 1, 2019 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save agragregra/832da69ca363ce1f1d8a4f72c36040c5 to your computer and use it in GitHub Desktop.
Save agragregra/832da69ca363ce1f1d8a4f72c36040c5 to your computer and use it in GitHub Desktop.
jQuery Input Field Filter
$(".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