Skip to content

Instantly share code, notes, and snippets.

@lolocoo
Created June 9, 2017 07:56
Show Gist options
  • Save lolocoo/f11084564239767efc45bdd72c215de8 to your computer and use it in GitHub Desktop.
Save lolocoo/f11084564239767efc45bdd72c215de8 to your computer and use it in GitHub Desktop.
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