Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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