Introducing jQuery
page 3 of 4
by Debjani Mallick
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 7740/ 88

Adding a class

It is one of the common tasks that a developer performs on a web page - adding and removing classes. For adding a class, we have to use addClass() function.

Listing 9

$("a").addClass("tableStyle");

It has been assumed that tableStyle is a predefined class. Similarly for removing a class, we can use removeClass () function.

Chainability

jQuery allows us to concatenate together operations into a single expression. Every method within jQuery returns the query object itself, allowing the programmer to "chain" upon it. In other words, most of the jQuery wrapper methods returns a reference to the jQuery object itself so that we can go on adding operations to a single expression when we need to perform multiple manipulations on the wrapped object. Let us take the example of the statements below.

Listing 10

$('#someId').addclass('someClass');
$('#someId').show();

The operation performed by the above two statements can be performed in one statement as shown below.

Listing 11

$('#someId').addclass('someClass').show();

Like the above examples, there are a lot of functionalities which can be performed using jQuery using the minimal code.


View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 1 and 4 and type the answer here:

User Comments

Title: Nice article   
Name: vinay khanna
Date: 9/17/2009 6:31:10 AM
Comment:
nice article to start working on jquery
Title: useful resources   
Name: sudhir
Date: 2/9/2009 8:07:33 AM
Comment:
For peoples searching information related to using JQuery with ASP.NET here is link to useful resources.
http://tips.developersvoice.com/using-with-jquery-with-aspnet-resources.html
Title: Mr   
Name: Razvan Puscasu
Date: 10/27/2008 4:44:25 AM
Comment:
Simple and effective article. Thx for the introduction in the JQuery world.
Title: Nice Article   
Name: Joydip Kanjilal
Date: 10/19/2008 10:51:45 AM
Comment:
Nice and simple.

Thanks,

Joydip

Microsoft Most Valuable Professional (ASP.NET) in 2007 and 2008

Author:--

Entity Framework Tutorial(Packt Publishing)
Pro Sync Framework (APRESS)
ASP.NET Data Presentation Controls Essentials (Packt Publishing)
SAMS Teach Yourself ASP.NET Ajax in 24 Hours (Sams Publishing)

Blog: http://aspadvice.com/blogs/joydip/default.aspx
Title: Nice simple article   
Name: Daniel
Date: 9/26/2008 1:46:14 PM
Comment:
I was looking for some articles on jQuery and I found this article which really proved helpful for me. Thanks for the article.

Product Spotlight
Product Spotlight 






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2009 ASPAlliance.com  |  Page Processed at 11/21/2009 5:29:40 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search