Explaining the code

Now, let's discuss the code that we previously used. We used the following function in our code:

jQuery(document).ready(function(){
//our codes. 
});

This is a jQuery function that allows you to set your jQuery ready to be used. You can replace jQuery with a dollar sign ($) as shown in the following:

$(document).ready(function(){
//our codes.
});

You need to think where you want to apply jQuery. We have written <h1>Click Here!</h1> in our body tags. We wanted our Click Here! to do something when clicked and that's why we added a click function similar to the following format:

  jQuery('h1').click(function(){
    //our codes.
  });

The jQuery can be replaced with $ as earlier mentioned.

We added an alert function so that when we click on our ...

Get JavaScript Projects for Kids now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.