jQuery API

.pushStack()

.pushStack( elements ) Returns: jQuery

Description: Add a collection of DOM elements onto the jQuery stack.

  • version added: 1.0.pushStack( elements )

    elementsAn array of elements to push onto the stack and make into a new jQuery object.

  • version added: 1.3.pushStack( elements, name, arguments )

    elementsAn array of elements to push onto the stack and make into a new jQuery object.

    nameThe name of a jQuery method that generated the array of elements.

    argumentsThe arguments that were passed in to the jQuery method (for serialization).

Example:

Add some elements onto the jQuery stack, then pop back off again.

jQuery([])
    .pushStack( document.getElementsByTagName("div") )
        .remove()
    .end();

Support and Contributions

Need help with .pushStack() or have a question about it? Visit the jQuery Forum or the #jquery channel on irc.freenode.net.

Think you've discovered a jQuery bug related to .pushStack()? Report it to the jQuery core team.

Found a problem with this documentation? Report it to the jQuery API team.

* All fields are required
  • Richard_clifford

    Very useful function. Nice one!

    • Davidxiaozhi

      why?

  • Onur

    i couldn't even get what's the purpose of that :/

  • Jaymichris

    I also can't get it.

  • Andrea Romano

    It changed my life