아래 코드는 IE와 크롬에서 제대로 작동 (최신 버전)jQuery - even.keyCode가 Firefox에서 올바르게 인식되지 않습니까?
$('#searchBox').keyup(function() {
var searchTxt = $(this).val();
// if item contains searchTxt,
if ($('.item:contains("' + searchTxt + '")')) {
// hide the items that do NOT contain searchTxt
$('.item').not(':contains(' + searchTxt + ')').hide();
};
// capture backspace
if (event.keyCode == 8) {
// show item that contains searchTxt
$('.item:contains(' + searchTxt + ')').show();
};
// if search box is empty,
if ($('#searchBox').val() == "") {
// show all items
$('.item').show();
};
});
위의 코드는 "대소 문자 구분 라이브 검색"을 수행하고 파이어 폭스에서 백 스페이스 키를 캡처 코드의 덩어리를 실행하는 데 실패
// capture backspace
if (event.keyCode == 8) {
// show item that contains searchTxt
$('.item:contains(' + searchTxt + ')').show();
};