2010-06-06 100 views
0
<link rel="stylesheet" type="text/css" href="jquery-ui-1.8.2.custom.css" /> 
<script src="jquery-1.4.2.min.js" type="text/javascript"></script> 
<script src="jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script> 


<body> 
Search: <input id="example" /> 
</body> 

<script> 
$(document).ready(function(){ 
var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" "); 
$("#example").autocomplete(data); 
}); 
</script> 
+3

你在哪裏包括自動完成插件?這不是jQuery核心的一部分。 – x1a4 2010-06-06 15:07:29

+0

謝謝。現在我知道了。 – Philip007 2010-06-07 10:26:26

回答

2

既然你的例子是直接從Autocomplete plugin page,我猜這就是你試圖使用的插件。你需要下載它並將它放在代碼可以使用的地方。

<script src="http://code.jquery.com/jquery-latest.js"></script> 
<!-- You'll want to change this next line to your local copy of the plugin. --> 
<script src="jquery.autocomplete.js"></script> 

Search: <input id="example" /> 

<script> 
$(document).ready(function(){ 
var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" "); 
$("#example").autocomplete(data); 
}); 
</script> 
+0

我按照你所說的在IE8中運行腳本並在輸入字段中輸入後得到錯誤消息: // IE8的錯誤消息網頁錯誤詳細信息 用戶代理:Mozilla/4.0(compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.2)時間戳:Mon,7 Jun 2010 23:13:10 UTC 消息:Object expected Line:570 Char:394 Code:0 URI:http://localhost/zhong/jquery-ui-1.8.2.custom.min.js – Philip007 2010-06-08 00:30:15

+0

我實際上使用了jquery/plugins的autocomplete(array)。但我打算使用從jquery/ui自動完成(源)。這兩個自動完成()具有相同的名稱,但不同的參數和不同的參考。這就是我犯錯的原因。 – Philip007 2010-06-08 01:17:21