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 text, there appears an alert box.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.172.132