Use Jquery in personal code ? Doesn't work like in FCC

Use Jquery in personal code ? Doesn't work like in FCC
0

#1

Hello,
I would like to use some JQuery in my website project’s html but it doesn’t work like there !
Should I download some program or copy a link in my html ?

Thank You !

(sorry for my english)


#2

Yeah, something like this:

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>

#3

Hey there,

The editor in FreeCodeCamp has jQuery built into it. When it comes to code you’re writing in your own code editor, jQuery isn’t automatically included, but it’s not hard to add!

There are two ways you can add jQuery to your personal code.

The first is that you can download the jQuery library locally onto your machine. An advantage to this is that you will have access to the jQuery library even if you don’t have internet access. A downside is that you would be stuck using that version of jQuery until you manually update the jQuery library within your project.

To add jQuery this way, you would download the file and place it in the same directory (folder) as your index.html. Then in your html <head> element you would call the jQuery library to be included in your project by writing:

<head>
   <script src="jquery-3.1.1.min.js"></script>
</head>

If you don’t want to host jQuery locally on your machine, you can use something called a CDN (Content Delivery Network) to include jQuery in your project. This way you don’t actually ever need to download jQuery yourself, rather your project will import the jQuery library every time your page runs. To do this, you would use code similar to the one above, but instead of the source being your local jQuery file, you would point to where it is hosted on the CDN.

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>