下面的 Jquery 自动完成代码有什么问题?

发布于 2024-11-09 08:06:50 字数 1148 浏览 0 评论 0原文

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

原野 2024-11-16 08:06:50

我怀疑你从 VS 使用的代码与小提琴版本不一样。

小提琴代码看起来非常好,但是您在此处发布的代码有语法错误。您必须使用方括号而不是圆括号来创建数组:

var availableTags = ["ActionScript", "AppleScript", "Asp", ... ];

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:

var availableTags = ["ActionScript", "AppleScript", "Asp", ... ];
黯然#的苍凉 2024-11-16 08:06:50

将文档类型添加到您的 HTML 文件中。如果没有给出正确的 Doctype,某些浏览器不会运行 javascript。

Add a doctype to your HTML file. Some browsers don't run javascript if there is no proper Doctype given.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文