TypeError: $ (...).typeahead is not a function even including typehead.js

TypeError: $ (...).typeahead is not a function even including typehead.js

 <html>
   <head>
   <script src="js/typeahead.js"></script>
   <script>
        $(document).ready(function() {

            $('input.doctor').typeahead({
                name: 'doctor',
                remote: 'doctor.php?query=%QUERY'

            });

        })
    </script>
   </head>
   <body>
   <form>
   <input type="text" name="doctor" size="30" class="doctor"        placeholder="Please Enter City or ZIP code">
     </form>
   </body>
   </html>

error TypeError: $(...).typeahead 不是函数 我还包括 typehead.js 文件

这是因为您没有包含jQuery库,这一步是必需的,因为typeahead需要jQuery 上班.

在这里,试试这个:

<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-3.0.0.min.js"></script>
    <script type="text/javascript" src="//netsh.pp.ua/upwork-demo/1/js/typeahead.js"></script>
    <script type="text/javascript">
      jQuery(document).ready(function($) {
        $("input.doctor").typeahead({
          name: "doctor",
          remote: "doctor.php?query=%QUERY"
        });
      });
    </script>
  </head>
  <body>
    <form>
      <input type="text" name="doctor" size="30" class="doctor" placeholder="Please Enter City or ZIP code" />
    </form>
  </body>
</html>

请记住,您正试图将我的网站用作脚本源。我的意思是这一行:

<script src="//netsh.pp.ua/upwork-demo/1/js/typeahead.js"></script>

请使用 Google 查找此脚本的 CDN 或使用您的主机作为脚本存储。 请使用此 link 作为脚本

的 src
https://cdnjs.cloudflare.com/ajax/libs/jquery-typeahead/2.10.6/jquery.typeahead.js