我刚刚意识到这段代码在Firefox中运行良好,但在IE 8中运行不正常.当用户在输入字段中输入至少8个字符时,我需要自动填充列表.
$('#inputField').keyup(function (event) {
var $inputField = $(this);
if ($inputField.val().length >= 8) { popularListBox(); }
});
function populateListBox(){
$.get("Default.aspx?name=test", function(data) {
$('#listBox').children().remove();
var options = data;
$("#listBox").html(data);
});
}
Run Code Online (Sandbox Code Playgroud)