This is killing me

This is killing me
0.0 0

#1

First of all, I would like to thank anybody in advance for taking the to help out.

Now, is there a coder out there using Atom with a Mac? If so, have you added Jquery to an HTML doc? HOW THE F did you do it??? There is nothing on youtube or other sites, I have been trying to. Codecademy and Freecodecamp train you well with Jquery but they dont teach you how to link it to an html doc to animate HTML elements! Please help.


#2

You add the <script></script> in the head section
https://www.w3schools.com/jquery/jquery_get_started.asp


#3

I don’t use a Mac, but pretty sure I don’t need to in order to answer your question. :wink:

Google “jquery cdn” to find a link that you can embed into a SCRIPT tag in your HTML. If you use CDNJS, they make it extra easy for you by providing the “Copy Script Tag with SRI” functionality. And use “jquery.min.js” when deploying final code to the Internet. You should use “jquery.js” only on your local machine when doing development.

Also don’t put SCRIPTs in the HEAD unless you have a really good reason to. A better place for them is the end of the BODY.


#4

Regardless of the editor or operating system, if you want to add JQuery to your HTML, just the put following at the bottom of your HTML page above the closing body tag. You can add it to the head, but for better performance put it in the body. Since you will not be able to access any objects referenced in the exteral JS file until the page is fully loaded, putting it at the end allows everything to load.

<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>

#6

Looking at the wording of your post you seem a bit frustrated. The users in this thread have provided suggestions for getting started. I recommend taking a break and coming back to this after you’ve calmed down.


#7

Yeah, just relax. I guarantee this is not the last time you’re going to be confused by something and beat your head against the desk trying to figure something out. I do it at least twice a day. It’s just part of coding and it gets amplified if you are self teaching.

To answer your questions, there are basically two ways to do it: remotely or locally.

Remotely, you would just google “jquery cdn” and get the remote address for it. Then you add it with a script tag.

<!DOCTYPE html>
<html>
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <!-- other head stuff -->
  </head>
  <body>
    <!-- the body of your code -->
  </body>
</html>

The other option is to do it locally. You download it and usually put it in some folder, like say “js”. Then you link to that local file.

<!DOCTYPE html>
<html>
  <head>
    <script src="js/jquery.min.js"></script>
    <!-- other head stuff -->
  </head>
  <body>
    <!-- the body of your code -->
  </body>
</html>

I guess I am confused by your statement, “There is nothing on youtube or other sites” I found several videos dedicated specifically to that subject. Similarly, a google search revealed many answers. Perhaps you were using the wrong search terms. I often have to try a few different combinations.

I know it can be frustrating. But researching things is part of the job. You will never know everything (especially since it keeps growing) so being able to find things is part of the job. Learn to enjoy the hunt. :wink: