var emails = [
{ name: "Peter Pan", to: "peter@pan.de" },
{ name: "Molly", to: "molly@yahoo.com" },
{ name: "Forneria Marconi", to: "live@japan.jp" },
{ name: "Master <em>Sync</em>", to: "205bw@samsung.com" },
{ name: "Dr. <strong>Tech</strong> de Log", to: "g15@logitech.com" },
{ name: "Don Corleone", to: "don@vegas.com" },
{ name: "Mc Chick", to: "info@donalds.org" },
{ name: "Donnie Darko", to: "dd@timeshift.info" },
{ name: "Quake The Net", to: "webmaster@quakenet.org" },
{ name: "Dr. Write", to: "write@writable.com" }
];
//emails的数组格式如上,formatItem代表的是显示的格式,formatMatch表示匹配的内容,formatResult表示结果的内容
$("#suggest13").autocomplete(emails, {
minChars: 0,
width: 310,
matchContains: true,
autoFill: false,
formatItem: function(row, i, max) {
return i + "/" + max + ": \"" + row.name + "\" [" + row.to + "]";
},
formatMatch: function(row, i, max) {
return row.name + " " + row.to;
},
formatResult: function(row) {
return row.to;
}
});
参数说明:
* minChars (Number):
* width (Number):
* max (Number):
* delay (Number):
* autoFill (Boolean):
* mustMatch (Booolean):
* matchContains (Boolean):
* selectFirst (Boolean):
* cacheLength (Number):
* matchSubset (Boolean):
* matchCase (Boolean):
* multiple (Boolean):
* multipleSeparator (String):
* scroll (Boolean):
* scrollHeight (Number):
* formatItem (Function):
* formatResult (Function):
* formatMatch (Function):
* extraParams (Object):
* result (handler)