Ajax-loader-large-white
jQuery Functions and Selectors
Functions, Part I: $(document).ready

Functions are the basic unit of action in jQuery. The main entry point of most jQuery applications is a block of code that looks like this:

$(document).ready(function() {
    Do something
});

Let's go through it bit by bit.

  • $(document) is a jQuery object. The $() is actually a function in disguise; it turns the document into a jQuery object.
  • .ready() is a type of function; you can think of it as sort of a helper that runs the code inside its parentheses as soon as the HTML document is ready.
  • function(){} is the action that .ready() will perform as soon as the HTML document is loaded. (In the above example, the Do something placeholder is where those actions would go.)
Instructions

Practice makes perfect! Set up your jQuery code in the script.js tab with $(document).ready() and pass it a function that will immediately hide the orange div on the Result tab. (You can use the jQuery .hide() effect to do this.)

?
Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

You should call .hide() on your jQuery object, like so:

$('selector').hide();

Where 'selector' is the HTML element you want to select.

index.html
stylesheet.css
script.js
project
View Preview