我有一个实时搜索框,其工作正常,除非用户删除内容,内容不会隐藏自己。隐藏输入内容被删除的内容(手动)
我的代码是:
$(document).ready(function(){
$('input[name=filter]').attr('autocomplete','off');
$("#filter").keyup(function(){
var filter = $(this).val(), count = 0;
$(".country li").each(function(){
if ($(this).text().search(new RegExp(filter, "i")) < 0) {
$(this).fadeOut();
} else {
$(this).show();
$('#call-content').show();
count++;
}
});
});
});
$("#clear").click(function() {
$('#filter').val('');
$('#call-content').hide();
});
的jsfiddle与HTML here
小提琴似乎工作正常 –