Search code examples
jqueryfade

Fading multiple elements simultaneously - jquery


I want to do the following:

$(newPanel, prevBtn, nextBtn, infoPanel).fadeIn(200, function() {
}

these vars are divs created with jquery

but only the first element fades in, I really need all elements to fade in at the same time.


Solution

  • You can use the add method to get the elements in the same jQuery object:

    newPanel.add(prevBtn).add(nextBtn).add(infoPanel).fadeIn(200);