-1

I am writing a simple webpage. I included jQuery and under the include, I alert a message but it dosn't show anything. I get uncaught reference error in the console.

<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Testing Media Queries</title>
    <script type="text/javascript" href="jquery-1.11.3.min.js"></script>
    <script>
      $( document ).ready(function() {
        console.log( "ready!" );
        alert('hello');
      });
    </script>
  </head>
  ...
Gab
  • 5,604
  • 6
  • 36
  • 52
Asif
  • 99
  • 1
  • 10
  • Is the path to jQuery proper? Did you check the network tab if its getting loaded? – Sandeep Nayak Oct 07 '15 at 17:29
  • That probably means that your attempt to load jQuery failed. Do you really have the file on your server at the correct place? You can use the browser developer tools to see whether it attempted to load it and whether the HTTP transaction succeeded. – Pointy Oct 07 '15 at 17:29
  • What is the file structure of your project? – Gab Oct 07 '15 at 17:37

1 Answers1

2

If you are trying to include a local file and the project's structure is like this:

|- test.html
|- jquery.js

Then in the header, the following will work (notice the use of src instead of href)

<script src="jquery.js"></script>

For more information about href vs src, see this.

If you don't want to host the file on your server, then consider importing it from the CDN like this:

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
Community
  • 1
  • 1
Gab
  • 5,604
  • 6
  • 36
  • 52
  • Really thanks issue solved :) i am using sublime text its giving me suggestions href not src that's why i have not noticed this :) thanks again – Asif Oct 07 '15 at 17:55