我建議正在研究使用jQuery UI的爲它的auto complete組件。
可以使用它來查看預定義的本地數據列表或在用戶鍵入時執行實時搜索。
使用一個靜態查找一個簡單的例子的代碼如下:
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$("#tags").autocomplete({
source: availableTags
});
});
</script>
<div class="demo">
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
</div><!-- End demo -->
<div class="demo-description" style="display: none; ">
<p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are tags for programming languages, give "ja" (for Java or JavaScript) a try.</p>
<p>The datasource is a simple JavaScript array, provided to the widget using the source-option.</p>
</div><!-- End demo-description -->
感謝,自動完成功能看起來還不錯。我會看看我能否實現它的工作。 – aknuds1
你有提供動態查找什麼建議嗎? – aknuds1
這就是你需要自己代碼的東西。 @尼古拉斯·默裏提供他的回答一個鏈接,說明這一側。 –