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

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

User Comments

Title: Nice article   
Name: vinay khanna
Date: 2009-09-17 6:31:10 AM
Comment:
nice article to start working on jquery
Title: useful resources   
Name: sudhir
Date: 2009-02-09 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: 2008-10-27 4:44:25 AM
Comment:
Simple and effective article. Thx for the introduction in the JQuery world.
Title: Nice Article   
Name: Joydip Kanjilal
Date: 2008-10-19 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: 2008-09-26 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-2024 ASPAlliance.com  |  Page Processed at 2024-04-24 1:01:03 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search