Vij*_*hna 10 javascript arrays jquery autocomplete
如何使用jquery autocomplete和简单数组的输入从字符串的开头启用完全匹配?
如果我在数组中有以下内容:
如果我在文本输入中键入"sma ...",我必须只显示智能和智能,而不是其他.
keu*_*une 14
您只需将源参数修改为一个功能,以满足您的需要.像这样:
更新:添加代码以回答:
var acList = ['smart', 'oversmart', 'smartland', 'undersmart', 'verysmart'];
$('#ac').autocomplete({
source: function (request, response) {
var matches = $.map(acList, function (acItem) {
if (acItem.toUpperCase().indexOf(request.term.toUpperCase()) === 0) {
return acItem;
}
});
response(matches);
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12542 次 |
| 最近记录: |