Thursday, September 9, 2010

Chaining it all together

One of the really powerful features of jQuery is chaining several statements together. Instead of re-using the selectors or calling the this keyword you can instead just run multiple jQuery commands all from the same line. It really is easy once you get the hang of it, you are just appending statements onto the end of the previous statement. Lets look at a paragraph tag element that is going to have the show and fadeIn actions chained together:

$('p:selected').show().fadeOut();

In this example our selected paragraph tag shows itself and then fades out. In theory you can chain as many together as you like.

No comments:

Post a Comment