Open In App

jQuery pushStack() Method

The pushStack() method in jQuery is used to add a collection of DOM elements onto the jQuery stack.

Syntax:

.pushStack(elements, name, arguments)

Parameters:

Example 1:




<!DOCTYPE HTML>
<html>
  
<head>
    <title>
        JQuery pushStack() method
    </title>
  
    <script src=
    </script>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;">
        GeeksForGeeks
    </h1>
      
    <p>
        JQuery | pushStack() method
    </p>
  
    <div
        This is div
    </div>
    <br>
  
    <button onclick="Geeks()">
        Click here
    </button>
      
    <p id="GFG"></p>
  
    <script>
        var el_down = document.getElementById("GFG");
  
        function Geeks() {
            jQuery([]).pushStack(
                document.getElementsByTagName("div"))
                .remove().end();
  
            el_down.innerHTML
                = "The DOM element <div> has "
                    + "been pushed to stack and then"
                    + " removed.";
        
    </script>
</body>
  
</html

  • Output:

  • Article Tags :