20 Feb 2020

jQuery Hello World

First, what is jQuery?

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.

jquery.com

Don’t think jQuery as a new technology. jQuery is rather a new approach to simplify client side web development like the HTML traversing with DOM and AJAX manipulation.
Kudos to the creator of jQuery John Resig.
Now lets get started to enter to the world of jQuery.
First of all, get a fresh copy of jQuery. You can download it from its homepage. jQuery.com
Now open your favorite text editor and create basic HTML wireframe.

<html>
<head>
<title>jQuery Hello World</title>
</head>
<body>
<!--body section-->
</body>
</html>

We have to include jQuery library. Put following code in the head section of your page.

<script src="jquery-1.3.2.js" type="text/javascript"></script>

I have assumed here you have kept your script file along with the html in the same folder.
Now lets add some jQuery thing. Put below code in the head section between script tag after including script file.

$(document).ready(function(){
// Your code here.
alert("Hello world from jQuery");
});

$() is the jQuery function and $(document).ready(function(){}) means that the function will be executed when the document is loaded. It is similar to the window.onload function in JavaScript.

Nilambar

PHP Programmer, WordPress and Laravel Developer, Freelancer and a Blogger.

View all posts by Nilambar →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.