jQuery自动完成在Firefox中运行良好,但在Chrome中则不然
jQuery autocomplete works fine in Firefox but not in Chrome
我在文本输入字段上有一个jQuery自动完成功能,它在Firefox中运行良好,但在Chrome中没有响应。这是该字段的脚本:
$(function () {
var availableTags = [
"La Plagne",
"Geneva"
];
$("#locationinput1, #locationinput2").autocomplete({
source: availableTags,
messages: {
noResults: '',
results: function () {}
}
});
});
您的代码在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 中工作
您的代码在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)"/>
相关文章:
- jQuery自动完成在Firefox中运行良好,但在Chrome中则不然
- Javascript下载在firefox中停止,但在Chrome中有效
- Javascript'元素'在ie中未定义,但在chrome和firefox中运行良好
- 这个jQuery代码在Mozilla上运行良好,但在Chrome,Opera,Safari上则不然
- 火狐中的多个问题,但在 chrome 中工作正常,没有一个问题
- 在Firefox中工作正常,但在Chrome中不能
- Javascript正则表达式在IE中失败,但在Chrome和Edge中工作
- Javascript键码在Firefox中不起作用,但在chrome中运行良好
- 输入类型的图像在Internet Explorer中不起作用,但在Chrome和Firefox中起作用
- Jquery.hide()和.show()在firefox上运行速度较慢,但在chrome上运行良好
- 在getJSON之后构建HTML在Safari中有效,但在Chrome或Firefox中无效
- JS函数如何/为什么不能'不能在代码中执行,但在chrome控制台中运行良好
- html数据属性在firefox中使用javascript时没有按预期显示,但在chrome中显示正确
- ng-click在IE中不起作用,但在CHROME中工作正常
- event.prventdefault()在mozilla中不起作用,但在chrome中运行良好
- 代码在firefox中运行良好,但在chrome中不起作用.为什么?
- 拖放文件时,dataTransfer.items属性在Firefox和IE中未定义,但在Chrome中未定义
- jQuery scrollTop没有'不能在FF或IE中制作动画,但在chrome中效果良好
- innerHTML=Date()在fiddle中工作,但在Chrome或IE中不工作
- Fullpage.js不能在Mozilla上运行,但在Chrome上运行良好