TypeError: $ (...).typeahead 不是一个函数,即使包括 typehead.js [英] TypeError: $ (...).typeahead is not a function even including typehead.js

查看:22
本文介绍了TypeError: $ (...).typeahead 不是一个函数,即使包括 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 文件

error TypeError: $(...).typeahead is not a function i am also includeing typehead.js file

推荐答案

这是因为你没有包含 jQuery 库,这一步是必需的,因为 typeahead需要 jQuery 才能工作.

This is because you did not include the jQuery library, this step is required because the typeahead library requires jQuery to work.

在这里,试试这个:

<!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>

这篇关于TypeError: $ (...).typeahead 不是一个函数,即使包括 typehead.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆