基于Bootstrap的Typeahead自动补全插件 Dynamic jQuery Typeahead Plugin For Bootstrap

示例一:使用source参数提供查询的数据源。


$(".typeahead").typeahead({
  source: [
    {id: "id1", name: "jQuery"},
    {id: "id2", name: "Script"},
    {id: "id3", name: "Net"},
    {id: "id4", name: "javascript"},
    {id: "id5", name: "java"},
    {id: "id6", name: "Php"},
    {id: "id7", name: ".Net"},
  ]
});						
					

示例二:通过json提供查询的数据源。


$.get("data.json", function(data){
  $(".typeahead").typeahead({ 
    source:data 
  });
},'json');	

//data.json的格式如下:
["jQuery","Script",".Net","Python","java","javascript","C++","CSS","HTML5"]