How to Use jQuery on Your Website
Decide whether you will use a CDN or host the jQuery file yourself., Create a tag in the head of your HTML document. , Inside your tag, type src="(Link to your jQuery file here, but don't include the parentheses)" ., Make sure the script tag is...
Step-by-Step Guide
-
Step 1: Decide whether you will use a CDN or host the jQuery file yourself.
Remember, since jQuery isn't a part of unaltered JavaScript, you will need to load the source code before running your own code.
A CDN (Content Delivery Network) has a free-to-use file that you can link to in order to load jQuery on your webpage. -
Step 2: Create a <script> tag in the head of your HTML document.
, Google's CDN is located at https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js. , Otherwise, jQuery will not work. , Writing type="text/javascript" is unnecessary because JavaScript is the default language for script tags in HTML
5. ,,, It should be a file from the official jQuery website, preferably the production version. , Again, writing type="text/javascript" is unnecessary because JavaScript is the default language for script tags in HTML
5. ,,, -
Step 3: Inside your tag
-
Step 4: type src="(Link to your jQuery file here
-
Step 5: but don't include the parentheses)" .
-
Step 6: Make sure the script tag is positioned before any script tags that use jQuery.
-
Step 7: Inside your HTML head
-
Step 8: create another script tag below your tag that loads jQuery.
-
Step 9: Within your tag
-
Step 10: type your jQuery code.
-
Step 11: Test your code once finished.
-
Step 12: Determine where you will host your jQuery file.
-
Step 13: Create another script tag after the tag that loads jQuery.
-
Step 14: Inside your opening script tag
-
Step 15: write src="(location of your file)".
-
Step 16: Make sure nothing lies between your script tags.
-
Step 17: Test to make sure your code works.
Detailed Guide
Remember, since jQuery isn't a part of unaltered JavaScript, you will need to load the source code before running your own code.
A CDN (Content Delivery Network) has a free-to-use file that you can link to in order to load jQuery on your webpage.
, Google's CDN is located at https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js. , Otherwise, jQuery will not work. , Writing type="text/javascript" is unnecessary because JavaScript is the default language for script tags in HTML
5. ,,, It should be a file from the official jQuery website, preferably the production version. , Again, writing type="text/javascript" is unnecessary because JavaScript is the default language for script tags in HTML
5. ,,,
About the Author
Amanda Murray
Brings years of experience writing about crafts and related subjects.
Rate This Guide
How helpful was this guide? Click to rate: