如何在一个页面上使用多个jQuery AutoSuggest?

时间:2011-02-24 11:07:44

标签: jquery autocomplete autosuggest

感谢您的回复。所以我没有在我的问题上添加更多细节。现在我正在解释整个问题..

我在我的页面中创建了一个Autosuggest,现在我想在同一页面中另外两个自动提取,这意味着页面中总共有三个自动提取。

我使用这个语法在我的页面中创建自动提示。

$("input[type=text]").autoSuggest("http://mysite.com/path/to/script", {minChars: 2, matchCase: true});

但是如果我将另外两个autosuggest放在一个页面中,那么我只获得第一个autosuggest值。意味着我不知道在jquery中放什么以及在HTML中放什么。

您能否给我一些简单的例子,在一个页面中创建三个自动提示..

提前多多感谢。

1 个答案:

答案 0 :(得分:0)

<input type="text" id="first" />
<input type="text" id="second" />
<input type="text" id="third" />


$("#first").autoSuggest("http://mysite.com/path/to/script/first", {minChars: 2, matchCase: true});

$("#second").autoSuggest("http://mysite.com/path/to/script/second", {minChars: 2, matchCase: true});

$("#third").autoSuggest("http://mysite.com/path/to/script/third", {minChars: 2, matchCase: true});