本帖最後由 pix756 於 2019-7-18 13:47 編輯
最近在開發網站,有使用到一個jQuery 的 autoComplete套件,
其中的語法有個符號 "~"代表什麼意思?
請各位先進解惑了,謝謝~
語法如下:
$("input[name='demo']").autoComplete({
minChars: 1,
source: function(term, suggest){
term = term.toLowerCase();
var choices = [book, phone, table];
var matches = [];
for (i=0; i<choices.length; i++)
if (~choices[i].toLowerCase().indexOf(term)) matches.push(choices[i]);
suggest(matches);
}
});
|