jQuery in 60 secs
The magic dollar sign ($) and a chain of operations
In jQuery, the most powerful character / symbol is the dollar sign. A
$()function normally returns a set of objects followed by a chain of operations. An example
- $("div.test").add("p.quote").html("a little test").fadeOut();
$("div.test").add("p.quote").html("a little test").fadeOut();
Think of it as a long sentence with punctuations. Indeed it is a chain of instructions to tell the browser to do the following:
- Get a div with class name is test;
- Insert a paragraph with class name is quote;
- Add a little text to the paragraph;
- Operate on the DIV using a predefined method called fadeout.
So there it is, the first two basics:
$()and chainable.jQuery Selectors
JQuery uses CSS selectors to single out one element or a group of elements, and normally we use a combination of them to target specific elements. For example:
$(‘p.note’)returns all<p>elements whose class name is note;
$(‘p#note’)returns the<p>element whose id is note;
$(‘p’)returns all<p>elementsTo select a child or children, we use the right angle bracket (>), as in
$(‘p>a’)(returns all of the hyper links within the<p>element);To select element(s) with certain attributes, we use [], as in
input[type=text](returns all text input element);To select a container of some other elements, we use has keyword, for example:
$(‘p:has(a)’)(returns all<p>elements that contains an hyperlink);jQuery also has a position-based selector for us to select elements by position, for example
$(‘p:first’)Document.Ready()
The most commonly used command in jQuery is
Document.Ready(). It makes sure code is executed only when a page is fully loaded. We often place code blocks inside thisDocument.Ready()event. For example:
- $(document).ready(function(){
- $("#buttonTest").click(function(event){
- alert("I am ready!");
- });
- });
$(document).ready(function(){ $("#buttonTest").click(function(event){ alert("I am ready!"); }); });
For more info please visit Xun Ding’s excellent article Using jQuery with ASP .NET

Thanks a lot, that was really helpful