jQuery Beginners Guide

Adding jQuery to your Page
jQuery is a client script library and so you have to add a script reference to your page. You can download the latest version of jQuery from the jQuery site at www.jQuery.com.

Here are many ways that you can include jQuery into your page:

1. Reference a local copy via tag in the page
2. Reference a local copy with ScriptManager
3. Embed script from Resource using the ClientScript object
4. Reference a remote copy from jQuery.com or Google Ajax API

Getting started with Selectors
You can select a single element:
$(“#gdEntries”).css(“border”, “solid 1px navy”);

Or select by class (.):
$(“.gridalternate”).css(“background”, “lightsteelblue “);

or from a couple of classes (, like in CSS separates multiple selectors):
$(“.gridrow,.gridalternate”).attr(“tag”, “row”);

You can also select elements (plain element) and apply filters to the elements. The following selects all buttons in a document and attaches a click handler:

$(“input:button “).click(function(event) { alert(“clicked”); });

A more complex example might select all rows in a table:
$(“#gdEntries>tbody>tr”).css(“border”, “solid 1px red”);

Refer this link: http://www.west-wind.com/presentations/jquery/

Share