Forked from agragregra/jquery-filter-by-field.js
Last active
September 29, 2017 14:24
-
-
Save kovtunos/cd1402f439285e72d739675eb344f98c to your computer and use it in GitHub Desktop.
jQuery Input Field Filter #jquery #form
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