What is jQuery?

Based on my understood, jQuery is a javascript lib; it is an extension of js. Just like J2EE is an extension of J2SE. The purpose of jQuery is to make it much easier to use JavaScript on your website.

Thus to learn jQuery, you must have some basic ideas about HTML, js and css.

Basic syntax is: $(selector).action()

A $ sign to define/access jQuery (you can change the $ symbol to what you like)
A (selector) to “query (or find)” HTML elements
A jQuery action() to be performed on the element(s)

Here is a sample:

$(“#flip”).click(function(){
$(“#panel”).slideDown(“slow”);
});

what is #flip here? #flip is a div.

<div id=”flip”>Click to slide down panel</div>

what is slideDown()? it is the action mentioned above.

All jQuery methods should be inside a document ready event

$(document).ready(function(){

// jQuery methods go here…

});

This is to prevent any jQuery code from running before the document is finished loading (is ready).

What is next? Practice!

You should get familiar with jQuery effects and AJAX. Then you are able to write perfect jQuery effects.

Advertisements