In the previous post of jQuery for beginners, we saw what do you mean by jQuery? what are its build types? what version you should download? and what $ symbol stands for?
In this post, we are moving a step ahead to see how should we include jQuery in our page and we’ll go on to write our first “Hello World” jQuery snippet.
To brief, we are going to learn two important points about jQuery and those are:
- How to include jQuery with reference to a script.js file and with reference to CDN (Content Delivery Network)
- Getting feedback from browser about page readiness
And this is how jQuery is included with reference to CDN
Note: Use CDN approach only if your application can communicate with CDN over the Internet
If your application is a desktop version, this this is how you should include it in your code
By now, we have included jQuery in our code. Let’s now see how do we get feedback from browser about page readiness.
$(document). ready is the function which checks if document i.e. page is ready to execute script code.
let’s now see how to write our first jQuery snippet?
Copy and paste this snippet in note page and execute.
How it works?
After we make sure that document is ready, we can call any function for execution. It could be selecting certain elements and assign CSS attributes to them. Or as in our case, we can simply call an alert function to say “Hello World”.
After completely going through this post, you should be able to
- Understand structure of jQuery and how to include it
- How to get feedback from browser and make sure the document is ready?
- Write your first jQuery snippet
You Don't Need a Bribe To Join
Plain and Simple. Do you enjoy what you just read? Did you get help to solve a work issue or learn something new? Cool, then get more in your inbox whenever we publish a new post