0

私は jQuery を初めて使用し、さらに単純なスクリプトを使用して単純な index.html を作成しました。ただし、firebug コンソールで次のエラーが表示されるため、jQuery ライブラリが読み込まれないようです。

TypeError: $ is not a function
$(document).ready(function() {

以下は私のindex.htmlです:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Online Calorie Tracker and Analyzer</title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
     <script src="http//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="js/bootstrap.js"></script>
    <script src="initialize.js"></script>
  </head>
  <body>
    <div class="container">
      <h1>Calorie Tracker and Analyzer</h1>
          <div class="navbar">
              <div class="navbar-inner">
                <div class="container">
                  <ul class="nav">
                    <li class="active"><a href="index.html">Home</a></li>
                    <li><a href="#">Track Food</a></li>
                    <li><a href="#">Analyze Food</a></li>
                    </ul>
                </div>
              </div>
            </div>
      <div class="hero-unit">
    <h1>A healthy you begins with tracking and analysis</h1>
     <p>10 out of 10 doctors agree. Losing weight is healthy. With our online calorie tracker and analyzer, the power is in your hands!</p>
     <button class="btn btn-danger" id="btn1">Get Started</button>
 </div>
    </div>


  <body>
<html>

jQuery スクリプトは次のとおりです。

$(document).ready(function() {
    alert("hello");
});

どんな助けでも大歓迎です!

4

2 に答える 2

0

私は同じ問題に直面していましたが、インターネットの問題も原因で発生します。タイムアウトが原因で、cdn がライブラリを読み込めないことがあります。この場合、ライブラリをダウンロードしてプロジェクトで使用してみてください: http://jquery.com/download/

于 2015-03-21T14:58:41.673 に答える