Last active
April 1, 2019 08:49
-
-
Save agragregra/832da69ca363ce1f1d8a4f72c36040c5 to your computer and use it in GitHub Desktop.
jQuery Input Field Filter
This file contains hidden or 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
$(".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