-2

I have my "good.html" and "jquery.js" file in a folder on desktop called "jquery2."

Here is my code

<!doctype html>
<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="jquery.js"></script>
</head>
<body>
    <script type="text/javascript">
        $(document).ready(function(){
            console.log('ready');
        });
    </script>
</body>
</html>

4 Answers4

2

Your

<script type="text/javascript" src="jquery.js"></script>

is not referencing the file on your desktop.

In order to make this work, you should upload the files to a server.

Jason Gennaro
  • 34,535
  • 8
  • 65
  • 86
1

You don't need a server but you do need to use a good path to the javascript file on your desktop, on windows like so: <script type="text/javascript" src="C:\Users\username\Desktop\jquery2\jquery.js"></script>

works for me on windows 7 with chrome browser. console shows ready.

If I make the path bad, console shows "Uncaught ReferenceError: $ is not defined" followed by a red X box next to GET file:///C:/Users/wrongusername/Desktop/jquery2/jquery.js

sdjuan
  • 709
  • 6
  • 15
0

Its issue with your Javascript path... put on same folder of your code or

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>

more info Where do you include the jQuery library from? Google JSAPI? CDN?

Community
  • 1
  • 1
Sanjay Goswami
  • 1,386
  • 6
  • 13
-1
<script type="text/javascript">
        $(document).ready(function(){
            alert('ready');
        });
    </script>
AlexC
  • 9,657
  • 17
  • 64
  • 98