學(xué)習(xí)要點(diǎn)
郵箱的自動(dòng)補(bǔ)全,下面這段代碼千萬(wàn)不能放在首部,否則不顯示。
必須要利用的就是 result.term 獲取到用戶輸入的,然后和輸出到頁(yè)面中
具體見(jiàn)代碼
$("#email").autocomplete({
autoFocus:false, //自動(dòng)獲取焦點(diǎn)關(guān)閉
delay:0, //延遲關(guān)閉
source:function(result,shuchu){
var host = ['qq.com','163.com','263.com','gmail.com','eyou.com']; //設(shè)置域名
var shuru = result.term; //獲取到用戶輸入的
var index = shuru.indexOf('@'); //獲取到序號(hào)
var result = []; //最終的結(jié)果
if(shuru.indexOf("@")==-1) // 當(dāng)用戶沒(méi)有輸入@則拼接
{
for(var i=0;i<host.length;i++)
{
var result1 = shuru+"@"+host[i]; //拼接
result.push(result1); //數(shù)組拼接
}
}
shuchu(result); //輸出結(jié)果
}
})