Lesson: jQuery
Learn how Script Tags and Document Ready Work
Now we're ready to learn jQuery, the most popular JavaScript tool of all time. Don't worry about JavaScript itself - we will cover it soon.
Before we can start using jQuery, we need to add some things to our HTML.
First, add a script
element at the top of your page. Be sure to close it on the following line.
Your browser will run any JavaScript inside a script
element, including jQuery.
Inside your script
element, add this code: $(document).ready(function() {
to your script
. Then close it on the following line (still inside your script
element) with: });
We'll learn more about functions
later. The important thing to know is that code you put inside this function
will run as soon as your browser has loaded your page.
This is important because without your document ready function
, your code may run before your HTML is rendered, which would cause bugs.
script
element making sure it is valid and has a closing tag.$(document).ready(function() {
to the beginning of your script
element.$(document).ready(function() {
function with });
Correct, congratulations!
Next problem: Target HTML Elements with Selectors Using jQuery
Try again
The content on this page is licensed under Attribution-ShareAlike 4.0 International. Original authors: freeCodeCamp, the content was modified.