How to use jQuery.wrapAll() method in jQuery?

jQueryWeb DevelopmentFront End Technology

The wrapAll() method wraps all the elements in the matched set into a single wrapper element.

Here is the description of all the parameters used by this method −

  • elem − A DOM element that will be wrapped around the target.


You can try to run the following code to learn how to use jQuery.wrapAll() method in jQuery −

Live Demo

      <title>jQuery wrapAll() method</title>
      <script src = ""></script>
         $(document).ready(function() {
           $('ul.myclass > li:lt(2)').wrapAll('<div class="demo"></div>')

         .demo {
            border: 3px dashed blue;
            margin: 5px;


      <ul class="myclass">
Updated on 14-Feb-2020 10:03:16