Reputation: 152
I have issue with browser, I have code in jsfiddle which shows me match result by providing input. but it working fine in FF not in IE
jquery version in jsfiddle is jquery 1.9.1 IE ver. 9 , FF version 24.0
$("#searchInput").keyup(function () {
//split the current value of searchInput
var data = this.value.toLowerCase().split(" ");
//create a jquery object of the rows
var jo = $("#selectbox").find("option");
if (this.value == "") {
jo.show();
return;
}
//hide all the rows
jo.hide();
//Recusively filter the jquery object to get results.
jo.filter(function (i, v) {
var $t = $(this);
for (var d = 0; d < data.length; ++d) {
if ($t.is(":contains('" + data[d] + "')")) {
return true;
}
}
return false;
})
//show the rows that match.
.show();
});
Upvotes: 1
Views: 85
Reputation: 2725
try this:
// on keydown on text box
$("#txtInput").on("keyup", function (e) {
var txt = $(this).val().toLowerCase();
//if backspace pressed refresh list
if (e.which == 8) {
if (txt.length == 0) {
renderList(arrText);
}
}
if (txt.length >= 1) {
var filterList = searchInList(arrText, txt);
if (filterList.length > 0) {
renderList(filterList);
} else {
renderList(arrText);
}
}
});
will also work in IE9 as well, fiddle here: http://jsfiddle.net/m25UW/1/
Upvotes: 1