作爲用戶輸入類型我正在搜索表並顯示結果相應。如何使自動完成退格工作在這種情況下
我提出了一個條件來檢查,如果輸入的輸入的長度至少大於或等於2。(但清除值之後其未顯示所有數值)
這是我的代碼
$('#searchequip').keyup(function(){
if ($(this).val().length >= 2) {
$('#errmsgnoequip').hide();
var val = $.trim(this.value).toUpperCase();
var noElem = true;
$('.mt-checkbox').each(function(){
var parent = $(this).closest('li'),
length = $(this).text().length > 0;
if (length && $(this).text().search(new RegExp(val, 'i')) < 0)
{
parent.fadeOut('slow');
} else {
noElem = false;
parent.show();
}
});
if (noElem)
$('#errmsgnoequip').html('No Results Matched').show();
}
});
http://jsfiddle.net/e08o7uct/34/