我使用MagicSuggest自动补全输入文本,自动补全提要非常大,所以我无法完整下载,在他们的示例中,他们提供了以下代码:
JAVASCRIPT
$(document).ready(function() {
var jsonData = [];
var cities = 'New York,Los Angeles,Chicago,Houston,Paris,Marseille,Toulouse,Lyon,Bordeaux,Philadelphia,Phoenix,San Antonio,San Diego,Dallas,San Jose,Jacksonville'.split(',');
for(var i=0;i<cities.length;i++) jsonData.push({id:i,name:cities[i],status:i%2?'Already Visited':'Planned for visit',coolness:Math.floor(Math.random() * 10) + 1});
$('#ms3').magicSuggest({
selectionPosition: 'bottom',
renderer: function(city){
return '<div>' +
'<div style="font-family: Arial; font-weight: bold">' + city.name + '</div>' +
'<div>Cooooolness: ' + city.coolness + '</div>' +
'</div>';
},
minChars: 1,
selectionStacked: true,
data: jsonData
});