Created
June 9, 2017 07:56
-
-
Save lolocoo/f11084564239767efc45bdd72c215de8 to your computer and use it in GitHub Desktop.
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
var $seach, $list; | |
$seach = $('#seach'); | |
$list = $('#list'); | |
$seach.on('keydown', function(){ | |
var $this = $(this); | |
setTimeout(function(){ | |
var val = $this.val(); | |
var re = new RegExp(val); | |
var newlist = $list.find('li').filter(function(item){ | |
console.log(re.test($(this).text())); | |
return !re.test($(this).text()); | |
}); | |
$list.find('li').show(); | |
newlist.hide(); | |
}, 0); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment