I have a UL that contain any number of LIs. I am trying to create some jQuery code that will parse the original UL and wrap a UL and another LI after every 5 of the original
You can do this:
var lis = $("#original_ul li");
for(var i = 0; i < lis.length; i+=5) {
lis.slice(i, i+5)
.wrapAll("
");
}
This keeps them in the same #original_ul
element, but you could just change the ID if that's necessary. This approach generates the exact output html you have in the question aside from the ID on the top