jquery - Wrapping range of children elements in a div -


So I'm trying to wrap elements of many children in the div so that they can manipulate groups; The scenario is trying to keep each group in a different place. The scenario is that I have a list that is generating a random li tag and no matter how many appear, I need every set of 10 separate .

To find out, I am using a written out list: / P>

  & lt; Div id = "access" & gt; & Lt; Div class = "menu" & gt; & Lt; UL & gt; & Lt; Li & gt; & Lt; P & gt; Hello & lt; / P & gt; & Lt; Ul & gt; & Lt; Li & gt; Content & lt; / Li & gt; & Lt; Li & gt; Content & lt; / Li & gt; & Lt; Li & gt; Content & lt; / Li & gt; & Lt; Li & gt; Content & lt; / Li & gt; & Lt; Li & gt; Content & lt; / Li & gt; & Lt; Li & gt; Content & lt; / Li & gt; & Lt; Li & gt; Content & lt; / Li & gt; & Lt; Li & gt; Content & lt; / Li & gt; & Lt; Li & gt; Content & lt; / Li & gt; & Lt; Li & gt; Content & lt; / Li & gt; & Lt; Li & gt; Stuff2 & lt; / Li & gt; & Lt; Li & gt; Stuff2 & lt; / Li & gt; & Lt; Li & gt; Stuff2 & lt; / Li & gt; & Lt; Li & gt; Stuff2 & lt; / Li & gt; & Lt; Li & gt; Stuff2 & lt; / Li & gt; & Lt; Li & gt; Stuff2 & lt; / Li & gt; & Lt; Li & gt; Stuff2 & lt; / Li & gt; & Lt; Li & gt; Stuff2 & lt; / Li & gt; & Lt; Li & gt; Stuff2 & lt; / Li & gt; & Lt; Li & gt; Stuff2 & lt; / Li & gt; & Lt; Li & gt; Stuff3 & lt; / Li & gt; & Lt; Li & gt; Stuff3 & lt; / Li & gt; & Lt; Li & gt; Stuff3 & lt; / Li & gt; & Lt; Li & gt; Stuff3 & lt; / Li & gt; & Lt; Li & gt; Stuff3 & lt; / Li & gt; & Lt; Li & gt; Stuff3 & lt; / Li & gt; & Lt; Li & gt; Stuff3 & lt; / Li & gt; & Lt; Li & gt; Stuff3 & lt; / Li & gt; & Lt; Li & gt; Stuff3 & lt; / Li & gt; & Lt; Li & gt; Stuff3 & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; / Div & gt;   

Now I can easily wrap the children by using a div in 10:

  $ ("ul li ul li li: Nth-child (N + 11) "). Wrap ("& lt; span class = 'shift' / & gt;");   

But this is certainly not necessary for me.

Here is the code that I am working now.

  var calculation = $ ("ul li ul li") Length; For (var c = 11; c & lt; = count; c + = 10) {$ ("ul li ul li: nth-child (n +" + c + ")"). WrapAll ("& lt; span class = 'shift' / & gt;"); }   

This works but this change creates a nested example of the class.

I need a separate wrapper device if I wanted to make the code, it would be:

  $ ("ul li ul li: nth-child (" + c + "& Lt; n & lt;" + (c + 10) + ")"). WrapAll ("& lt; span class = 'shift' / & gt;");   

But obviously it will not work before doing something like this

You can try the method:

  // Note: Unlike nth-child, Slice is 0-based position $ (" ul li ul li "). Piece (c, c + 10) WrapAll ("& lt; span class = 'shift' / & gt;");    

Comments