我有一個實時搜索框,其工作正常,除非用戶刪除內容,內容不會隱藏自己。隱藏輸入內容被刪除的內容(手動)
我的代碼是:
$(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
小提琴似乎工作正常 –