我在创建的Datalist自动填充功能方面存在问题,如果您在Chrome中运行它,则可以按名称或ID进行搜索,例如,您可以输入Doe并获取John Doe的结果。或者你可以输入11109,它会给你John Doe。 在IE中,您只能输入ID而不是名称才能获得结果。 此外,我确信没有太多可以做到这一点,但在Chrome中,下拉列表显示ID和名称旁边的名称,其中IE仅显示名称。 如果可能的话,我可以让IE在两种情况下都更像Chrome(我更关心通过ID和名称进行搜索)
var json = [{
"UserID": 17,
"PSID": "1110959",
"Name": "Doe, John",
"Email": "John.Doe@somesite.com",
"Level": "25",
"Manager_Name": "Doe, Jane",
"Manager_PSID": "1014009",
"Manager_Email": "Jane.Doe@somesite.com",
"Manager_Level": "19",
"CompFile": null
}, {
"UserID": 50,
"PSID": "1114187",
"Name": "Smith,Kevin",
"Email": "Kevin.Smith@somesite.com",
"Level": "27",
"Manager_Name": "Herman, Mike",
"Manager_PSID": "1178148",
"Manager_Email": "Mike.Herman@somesite.com",
"Manager_Level": "25",
"CompFile": null
}, {
"UserID": 123,
"PSID": "1119167",
"Name": "Black, Clint",
"Email": "Clint.Black@somesite.com",
"Level": "19",
"Manager_Name": "Dwezel,Beth",
"Manager_PSID": "1001375",
"Manager_Email": "Beth.Dwezel@somesite.com",
"Manager_Level": "43",
"CompFile": null
}];
$('#EmployeeSearch').on('keyup', function (e) {
var term = this.value;
//delay(function () {
//}, 1000);
$('#huge_list').empty();
$.each(json, function (i, item) {
$('<option/>', {
'value': item.PSID,
'text': item.Name
}).appendTo('#huge_list');
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="EmployeeSearch" list="huge_list" />
<datalist id="huge_list"></datalist>
&#13;