正确的。我花了大约 4 个小时才发现这个 .autocomplete 的小错误。
由于我又傻又累,我重新提出了这个问题,我有不同的源文件。
这有效:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"</script> <!-- -->
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.12/jquery-ui.min.js"</script> <!-- -->
但不是这个:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"</script> <!-- -->
<!--<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.12/jquery-ui.min.js"</script> <!-- -->
也不是这个:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<!--<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"</script> <!-- -->
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.12/jquery-ui.min.js"</script> <!-- -->
这是文件:
function querypage_to(element, str)
{
var availableTags = [
"ActionScript",
"Scheme"
];
$("input#to").autocomplete({
source: availableTags
});
}
</script>
<div>
<form>
<input id="to" type="text" onkeyup="querypage_to(this, this.value);" placeholder="To" autocomplete="on" ><br />
<input type="text" onkeyup="querypage_from(this, this.value);" placeholder="From" autocomplete="on" ><br />
<!--<input onfocus="handleFocus(this);" onblur="handleBlur(this);" value="From" type="text" onclick="querypage_from(this.value);" placeholder="From" ><br />
<!--<input type="text" id="someInputField" value="Suggestion..." onfocus="handleFocus(this);" onblur="handleBlur(this);">-->
</form>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js"</script> <!-- -->
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.12/jquery-ui.min.js"</script> <!-- -->
为什么是这样?
#回答:我错过了“>”,该死的菜鸟错误!