All right.
So let's go and dive right in to writing some jay queery code.
I have my index file open right here and we went ahead in the last class and added the link to the query
and we made sure that that worked within the browser we tested all that out.
So now I have the library queries a library and now that we have that added here we can go ahead and
start.
Now we can go ahead and connect to it by adding some scripting code in here.
So let's get started.
I have to do is open up a tag and say
script
Meskin open and closed.
When I go ahead and I get myself a little space here so I can type in between there.
Now again this was just linking to the query.
Now we create a new script to actually write some kind of a function within here.
So the way you write Gigue query is you start out by adding a dollar sign.
Now that allows you to link to the different things within their so and the dollar sign that's how we
referenced the Jake word code there.
Now what we do is we open up a set of parentheses and quotes.
This is how we target our selector.
We add the again be open and closing parentheses and opening closing quotes and here in there is where
we start to say what we're going to target and target our document the whole document we're going to
target that whole thing.
I can also put it in there very specific things within CSSA or different things you going to see how
we target all that stuff later on.
Right now I want to target the entire document.
So now after that I must say ready now this is a function this is says when this is ready this is what
is going to happen.
We say ready and then we open up another set of parentheses and we say the function of this is a callback
function that is going to allow us to do other things.
So just bear with me on this one we're going to open and close our parentheses and we're going to open
and close lips your own unclose is that a curly brackets right.
All right so I type that out between the Crilley brackets right damnum place my cursor so you can see
it's blinking right there when I hit return a couple of times.
Now in here we're going to add a nother selector.
Can we added the first one to appear.
I do a dollar sign and with in there must say open quote MSA body X. Well done so far as we said OK
with them the document once it's ready start this function here.
This is the event handler up here and we're to say make sure that all the stuff is ready and then target
the body acts.
Now what I want to do and I've written all this to say the Dykeman starts once that's ready within the
body that what you want to do and want to do in this case I wanted to append that means to add to almost
a append and going to open up a new set of parentheses here and news of the quotes I want to aren't
pinned to the body is like put anything in here that I wanted to get at an image taken in a text I can
do whatever I wanted to in this case when I do something very simple as why that little bit of each
team comes in each one I love Jake Weary and just like with River.
Each team element to go ahead and close that out and do is a need to add a semi-colon right there so
they know that's all done.
So if you're adding this with regular javascript this would take a lot more code than this.
This is what's really great if you are not familiar with just writing regular javascript you would not
appreciate this as much.
But with this very simple little function right here I'm able to add this text to the body of my document.
Because of that little room right there one less thing I've got to do.
Just like with everything else each time LJ group seems as I need to make sure I'm always closing things
out properly so I have that little Simak want I needed to add right down there.
But I've got that in there that's why and save our document and we'll come back to her.
Imelda I can get here soon.
I'm still looking at the news source code up here.
Now this was filed before regular old index that each team element to hit refresh rate there and you
can see that my text is put right into the document or control click or you get it right click whatever
and say inspect and you can see that it added that dynamically right into the document so you can start
to see hopefully that the power of Jake where we right here I can just add information right into my
document wherever I want to I can start to really target different things and here I could target CSSA
ID areas different things like that you can switch things up on the go.
Makes this stuff very powerful and opens up a lot of doors for you to do some really cool things.
You'll be sane in future classes here.