我在文本输入字段上有一个jQuery自动完成功能,在Firefox中工作正常但在Chrome中没有响应。以下是该字段的脚本:
$(function () {
var availableTags = [
"La Plagne",
"Geneva"
];
$("#locationinput1, #locationinput2").autocomplete({
source: availableTags,
messages: {
noResults: '',
results: function () {}
}
});
});
答案 0 :(得分:0)
您的代码在Chrome中适用于我。你有<head>
标签中的jQuery和jQuery UI,它们都放在自动完成脚本之上吗?
示例:
<script type="text/javascript" src="//code.jquery.com/jquery-2.0.2.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
$(function () {
var availableTags = [
"La Plagne",
"Geneva"
];
$("#locationinput1, #locationinput2").autocomplete({
source: availableTags,
messages: {
noResults: '',
results: function () {}
}
});
});
</script>
JSFiddle - 在Chrome中工作
答案 1 :(得分:-1)
您的代码在Chrome中运行良好。您能否告诉我们您使用的是哪个版本的Chrome? 我使用的是版本41.0.2272.118 m,代码适用于我。 同样在控制台中检查是否有任何javascript错误。 如果它即将到来然后首先解决该错误。它需要解决所有的JavaScript错误。我正在放置我尝试过的代码。您可以单击“运行代码片段”来检查代码的工作方式。
$(function () {
var availableTags = [
"La Plagne",
"Geneva"
];
$("#locationinput1, #locationinput2").autocomplete({
source: availableTags,
messages: {
noResults: '',
results: function () {}
}
});
});
<script type="text/javascript" src="http://code.jquery.com/jquery-2.0.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<input id="locationinput1" type="text" name="origin" placeholder="From (Airport/Resort)"/>
<input id="locationinput2" type="text" name="destination" placeholder="To (Airport/Resort)"/>