jQuery for Beginners – Step by Step Tutorial (Part 1)

Date: February 5th, 2010
Author: Ivory Morhuld

jQuery is JavaScript framework, which makes very easy development of JavaScript applications. Moreover jQuery will guaranty you that your application will work on most popular web browsers used today. jQuery makes available many DHTML effects, AJAX requests, DOM modifications, etc. to be used with light source code and rapid development by web programmers.

Main advantages of jQuery is this, that you don”t need to add anything to document body, but you can separate all interactivity JavaScript in separate functions in external files. You can see this later in this tutorial.

If you want to make any modification on any DOM object will need to load completely entire document. To be sure this is a true, and without using jQuery you have to write something like this:

  1. <body onload="function(…)">

With jQuery we will just use ready event:

  1. $(document).ready(function() {
  2.     // do something after full loading of document
  3. });

Now lets make an simple, but fully functional example. Lets say, that you want, after fully load of document to display alert if the visitor click on any link:

  1. $(document).ready(function() {
  2.     $("a").click(function() {
  3.     alert("jQuery");
  4.     });
  5. });

Now lets examine the above code. Like you see, we wait document to be fully loaded with ready event. After document is completely ready for manipulation, selector $("a") selects all a elements.

By using $() in jQuery we initialize new object. Click function, which is standard JavaScript function inserts in selected object (in our case this is all a elements) click event and every time execute this function when click on any link. In other word – jQuery adds to any link, one onClick event like this:

  1. <a href="#" onclick="alert('jQuery')">Link</a>

Now you can follow next part of jQuery for Beginners Tutorial.

VN:F [1.9.18_1163]
Rating: 7.1/10 (20 votes cast)
jQuery for Beginners - Step by Step Tutorial (Part 1), 7.1 out of 10 based on 20 ratings

5 Responses to “jQuery for Beginners – Step by Step Tutorial (Part 1)”

Leave a Reply