A basic question about jquery

I am trying to use jquery in my code.
I have downloaded the “jquery-3.2.1.js” to my computer, and I referenced it with the HTML script tag
like this <script src="/jquery/jquery-3.2.1.js"></script>
when I executed the code, the program did not work.

but when I changed it to <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>,the program did work.

My browser is Chrome.

I don’t know why. Promised the address is correct.

I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums

1 Like

Try removing the leading slash in the src.

2 Likes

Kev is probably right, it’s probably that the script tag is wrong. It should probably be:

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

It’s probably looking the wrong path. This would be easy to confirm - when you run the old version and open the console (probably ctrl-sft-j) there should be an error in the console saying that that file can’t be found. There are probably also errors about it not understanding your jQuery, natch.

The browser console is a web developer’s best friend. Learn to use it.

1 Like

Or put a dot before it, like this

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

Both assume your HTML file and your jquery folder are in the same parent folder.

1 Like

Thanks a lot!! I did it!

Thanks a lot! I did it!