0 points
Submitted by doofgod
over 8 years

How to run jquery on local machine

I’m trying to move all this code to my local machine, but I cannot get the script.js to run. I put the HTML, CSS, and JS in the same folder, and it looks like the HTML page is recognizing the css but not the js, for one reason or another. When I open the html doc with a browser, I do see the well-formed pull down, but when I click it, I can’t get the javascript to kick in… what am I doing wrong?

Answer 51227b697cab3a5a4c00174b

8 votes

Permalink

So i figured this out. You have to tell the webpage that you want to use jQuery and where it should get it. You can either put the latest jQuery file in on your server or link to it. Here is how i did it:

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

I simply downloaded jQuery from http://jquery.com/download/ Simply edit this so your path to the file is correct, and it should work :) Mine did!

It also works directly from the web by putting the link, like so:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="script.js"></script>

Hope it helps.

points
Submitted by Jonas Lomholdt
over 8 years

3 comments

doofgod over 8 years

Ah this is it. I included the link to the jquery website in my html file and everything works fine. I erroneously assumed that jquery was a standard part of the js package.

Vo Quoc Hung over 6 years

Thank you!

Rishi Kumar Pandey over 6 years

very helpful….