Autocomplete 是常見的自動完成外掛,可在使用者輸入時提供建議清單,常用於搜尋框、名稱選擇與快速填入。
$("#txtSelectName").autocomplete(objects, {
minChars: 0,
max: 5,
autoFill: true,
mustMatch: false,
matchContains: true,
scrollHeight: 200,
formatItem: function (row) { return row.name; },
formatResult: function (row) { return row.value; }
});
除了 JSON 物件陣列,也可使用 JavaScript 陣列或遠端資料。常見參數包含 minChars、max、delay、autoFill、mustMatch、matchContains、cacheLength 等,可依需求調整提示行為。