下面的 Jquery 自动完成代码有什么问题?
<html>
<head>
<title></title>
<script src="script/jquery-1.6.1.min.js" type="text/javascript"></script>
<script src="script/jquery.autocomplete.js" type="text/javascript"></script>
<script src="script/jquery-ui-1.8.13.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(window).ready(function () {
$(function () {
debugger;
var availableTags = ("ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme");
$("#tags").autocomplete({
source: availableTags
});
});
});
</script>
</head>
<body>
<div>
<input id="tags" type="text" />
</div>
</body>
</html>
这是它的 fiddle 链接,在 Fiddle 上工作正常,但在 VS 上不行
<html>
<head>
<title></title>
<script src="script/jquery-1.6.1.min.js" type="text/javascript"></script>
<script src="script/jquery.autocomplete.js" type="text/javascript"></script>
<script src="script/jquery-ui-1.8.13.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(window).ready(function () {
$(function () {
debugger;
var availableTags = ("ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme");
$("#tags").autocomplete({
source: availableTags
});
});
});
</script>
</head>
<body>
<div>
<input id="tags" type="text" />
</div>
</body>
</html>
Here's the fiddle link to it, works fine on Fiddle, but not from VS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我怀疑你从 VS 使用的代码与小提琴版本不一样。
小提琴代码看起来非常好,但是您在此处发布的代码有语法错误。您必须使用方括号而不是圆括号来创建数组:
I suspect the code you are using from VS is not the same as the fiddle version.
The fiddle code looks perfectly fine, but the code you posted here has a syntax error. You must use square brackets to create an array, not parentheses:
将文档类型添加到您的 HTML 文件中。如果没有给出正确的 Doctype,某些浏览器不会运行 javascript。
Add a doctype to your HTML file. Some browsers don't run javascript if there is no proper Doctype given.