Chaining stuff in JQuery

by Sanju 2012-07-05 09:42:36

Chaining stuff in JQuery

While doing common operations, you don’t need to call the element every time you want to manipulate it. If you’re doing several manipulations in a row, use chaining, so jQuery won’t need to get the element twice.

Instead of this:

$("#cont").hide();
$("#cont").css("padding-left", "30px");


Use this:

$("#cont").hide().css("padding-left", "30px");

Tagged in:

1059
like
0
dislike
0
mail
flag

You must LOGIN to add comments