O'Reilly logo

ASP.NET jQuery Cookbook - Second Edition by Sonal Aneel Allana

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Providing method chaining

Chaining more than one method is a very useful feature when programming in jQuery. Chaining is possible since most jQuery methods return an object allowing the calling of other methods on the returned object. Since the child methods are executed in the returned object instead of the entire DOM, the code runs faster. This allows you to write code, which is not only shorter but also faster.

The plugin that we have worked with so far does not support chaining. In this example, let's modify the plugin to include this feature.

The programming constructs used in this example are summarized as follows:

Construct

Type

Description

$

jQuery function

This refers to the jQuery function. $ is an alias for jQuery.

$("#identifier") ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required