Hello and welcome to this lecture on how to access J query library.
There are two main ways you can access feature query library.
You can download from J.
Query dot com or you can reference it from a content delivery network they will hosted for you or you
need to do these references using this source attribute some on the J.
Query dot com Web sites if you can just go to J.
Queried or com to download and click on the download button here
depending on what projects you want to use.
J.
Query for if your project is going to involve Internet Explorer 9 or less then you want to go for J.
Query version 1 x.
So there are two branches.
J.
Query one X and J.
Query 2 x 1 x supports Internet Explorer 9 or less.
If you want to use that but if your project doesn't include that you could come for the latest one which
is version to X.
There are two versions of J.
Query.
You've got the compressed and the uncompressed the compressed is usually used for a production development
environment because it makes a faster overlay network while the uncompressed is used for development
or debugging work.
So if you want to do development work or debugging or testing that is recommended that you use the uncompressed
version of a query.
So let me scroll down to I've already got a download that I'm just going to show you what to do.
So if you're going to use version to X if you don't need Internet Explorer 9 or less this is the version
you go for.
You download the compressed sorry the uncompressed because the compress is for a live production environment.
So if you're going to be using development work you'll be needing the compressed version.
This two part one is the current version.
Just double click or you right click and save link as.
Just double click and it should download to your download folder if you want to reference Jake query
from a content delivery network.
What.
This is a good way of doing it.
A lot of people access to query this way because it takes a hassle.
Also out of hosting query this content delivery networks their big networks they can host your query
for you and you don't need to worry about dating J query cause they automatically do it for you or you
need to do is reference the location of the content delivery network.
Just like as they've done yet you put the reference in your script tag where it's got the source attribute
you specify the location of the CDM you want to use your OK you can specify multiple ones but Google
is a very good one.
I'll be using Google for this course.
So if you want to click these are the various content delivery network on the J.
Query website if you wanted to use Google you click on the Google C then and then you go to the code
snippet so you go to libraries and the one you want.
So you just copy this script tag here and paste that into your text editor in the script.
So in the head section and this will give you access to the J query library.
This is my downloaded J query file.
This is your original it's really a small file is 2 for 1 kilobytes of you right click.
You see this size this a really tiny file 241 kilobytes so you can open it and see what's inside.
If you wish.
Once you've downloaded a query you can rename it like I've done here to make it easy for me to reference
so.
But if you don't want to rename it when you reference it in your source attribute you must include the
this the false path that is dash to point one point one point for you must include that if you remove
that extension then you can just name it as a J query dot js file.
So this is how you would use it in a local.
P.S. There are advantages and disadvantages of hosting a query yourself locally.
You don't get the updates regularly so you could miss out on the updates while if you're using a content
delivery network data all the hosting for you.
The updates are automatic so that's the difference between the CDM and hosting it locally.
So let me show you how you would reference it.
So this is a little piece of code I have written.
So this is the way you would include a query in your code usually to be in the health section or in
the script.
Just the very first part of the script.
So this is my local reference to J query because I have renamed it.
So that's why I've just got it as a J query the j as file and then this is my reference to the C the
N network.
This is a google link to the J.
Query library.
So for the duration of the course I'll be using the link from Google just in case there are any updates
during the course.
And I don't miss them.
Few if you're going to do locally.
Make sure you you reference it a name correctly.
If not you it will not work.
If you get the name wrong it will not work.
So make sure you reference Metro the source links to the name correctly.
All right.
Might be safer to just use the CDL network like I've done here.
So they were there so now we'll talk about the syntax.
So we've reference J query.
Let's talk of how you would write to check query code.
So this is how you specify a jerk query code between this script tag here.
So you go to the first script tag is a reference.
I've got two references here.
And then the main code is between the other script tag.
So you've always specify the source first where you get in J.
Query for specify the location of J.
Query and then you specify your code.
So the first line of code is this here is a document the ready function.
This is very important.
You find this line of code in most J query code.
What this does is an event handler function.
It listens out for the web page to make sure the web page has loaded correctly before this code will
execute.
That's the main purpose of the document ready function.
So every J query code is identified with the dollar sign.
Anyway you see a dollar sign.
You know you are referencing a J query library.
The dollar sign.
And then you've got this selector which is this document dot ready function which listens out for the
web page to load before the code on the need executes.
And the code here is this J query uses the uncle as a selector which is this Uncle Tiger this link he
uses that as a selector.
So what we're saying that when I click on this link the event that I want to happen is to make an unlocked
box pop up.
So when the link is clicked this allows lag alert box will pop up and then it would direct me to the
location of the link.
So let's check this out.
So we're going to test AJ queries working.
So if I click on this link here which is this year it should give me this alert and then redirect me
to the actual link.
So if I click on that that's the alert from that.
If I click OK it will now redirect me to this location.
So that means J.
Query is working and installed properly.
And this reference.
So one advantage also arsehole of having a query local and also from a CBN for example the first line
doesn't work if you can't find your query locally it will picture a query up from the CBN network below.
So I've specified it twice if he doesn't get it there he'll pick it up from here.
In this video I showed you how to download a query from the query dot com and also how to reference
it on on your old code and also using the content delivery network object query code must be preceded
with a dollar sign way you see a dollar sign you know you are referencing AJ query code.
Thank you so much for watching.