Uncaught TypeError: $(…).autocomplete is not a function

前端 未结 2 1531
无人共我
无人共我 2021-01-21 20:32

I\'m trying to implement a JQuery autocomplete text box. I couldn\'t get my custom one to work, so I\'m trying to implement the stock text box instead to begin with so I can fix

相关标签:
2条回答
  • 2021-01-21 21:14

    You need to include jquery library before jquery ui

    check this fiddle

    0 讨论(0)
  • 2021-01-21 21:34

    Change the beginning of your code with the one below. You are missing some files.

    <title></title>
        <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
      <script src="//code.jquery.com/jquery-1.10.2.js"></script>
      <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
      <link rel="stylesheet" href="/resources/demos/style.css">
    
    
        <script>
            $(function () {
    

    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>jQuery UI Autocomplete - Default functionality</title>
      <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
      <script src="//code.jquery.com/jquery-1.10.2.js"></script>
      <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
      <link rel="stylesheet" href="/resources/demos/style.css">
      <script>
      $(function() {
        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 class="ui-widget">
      <label for="tags">Tags: </label>
      <input id="tags">
    </div>
     
     
    </body>
    </html>

    0 讨论(0)
提交回复
热议问题