What is chaining in Jquery?

jQuery QuestionsCategory: GeneralWhat is chaining in Jquery?
Manda asked 2 years ago

What would be the benefit of chaining?

1 Answers
Joe Mendoza Staff answered 2 years ago

Heres an example:
$("#div1").css("color", "blue").slideUp(1000).slideDown(1500);

What's happening above is multiple commands are being applied to '#div1', they are happening in sequence, one after the other. The benefit is that the browser does not have to find the same element with every command. Below is the same example as above written in a slightly different format.

$("#div1").css("color", "blue")

Pin It on Pinterest