Unturect typeError:无法读取未定义的属性(读取'长度')。 JQuery的自动烟

发布于 2025-02-11 06:28:35 字数 675 浏览 0 评论 0原文

这里的简单代码正在尝试使用自动建议,

这是我为.js文件(内部(文档)函数)编写的自动码代码,

$(function () {
        var list = [
            "One",
            "two",
            "Three",
            "Four",
        ];
        debugger;
        $("#text").autocomplete({
           
            minLength: 0,
            delay: 0,  
            placeholder: "Select Transporter...",
            source: list
        });

html代码

<input type="text" id="text" value="text" />

错误显示为:

Uncaught TypeError: Cannot read properties of undefined (reading 'length')

无法看到任何动作。文本框。以上错误是在控制台中 请帮助我。并分享我可以学习和实施自动避难的链接

simple code here am trying for auto suggestion

this is my autosuggestion code for written in .js file (inside (document).ready function)

$(function () {
        var list = [
            "One",
            "two",
            "Three",
            "Four",
        ];
        debugger;
        $("#text").autocomplete({
           
            minLength: 0,
            delay: 0,  
            placeholder: "Select Transporter...",
            source: list
        });

html code

<input type="text" id="text" value="text" />

error showing as :

Uncaught TypeError: Cannot read properties of undefined (reading 'length')

not able to see any moves.after entering somthing then when i come out of textbox . this above error comes in console
please help me out . and share link where i can learn and implement about auto-sugestion

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

不离久伴 2025-02-18 06:28:35

来自 https://jqueryui.com/autocomplete/
确保您导入了这两个CDN

<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>

最终代码喜欢此

<!doctype html>
<html>

<head>
    <title>Online jQuery Editor</title>
    <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
    <script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>
</head>

<body>
    <input type="text" id="text" value="text" />
</body>
<script>
    $(document).ready(function () {
        $(function () {
            var list = [
                "one",
                "two",
                "three",
                "four",
            ];
            debugger;
            $("#text").autocomplete({
                minLength: 0,
                delay: 0,
                placeholder: "Select Transporter...",
                source: list
            });
        })
    });
</script>

</html>

From https://jqueryui.com/autocomplete/
make sure you imported these two CDN

<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>

final code would like this

<!doctype html>
<html>

<head>
    <title>Online jQuery Editor</title>
    <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
    <script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>
</head>

<body>
    <input type="text" id="text" value="text" />
</body>
<script>
    $(document).ready(function () {
        $(function () {
            var list = [
                "one",
                "two",
                "three",
                "four",
            ];
            debugger;
            $("#text").autocomplete({
                minLength: 0,
                delay: 0,
                placeholder: "Select Transporter...",
                source: list
            });
        })
    });
</script>

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