wrapall

Trying jQuery wrapAll seems to wrap the content twice

Hi guy, I got a markup looking like this : <body> <... a lot of tags from the web site ...> <script type="text/javascript" src="http://cdn.jquerytools.org/1.1.1/jquery.tools.min.js"&gt;&lt;/script&gt; <script type="text/javascript" src="my_script.js"></script> <body> I want it to end up that way : <body> <div...

Use JQuery to wrap multiple sets of elements in a Div

I'm working on a dropdown menu and need to mutate the existing html markup with JQuery to make it fit the design. Here is a simplified example: Wrap all "ul's" that contain more than one "li" in a div (in the same div, NOT one div for each UL). <ul> <li>foo</li> </ul> <ul> <li>foo</li> <li>foo</li> </ul> <ul> <li>foo</l...

Jquery .wrapAll problem

Hi Guys, I'm parsing an xml file and I want to wrap children divs into a div called "new": I have something similar to below: function parseXml(xml) { $(xml).find("hotel").each(function() { $('<div class="wrapme"></div>').html($(this).find("hotel_name").text()).appendTo('#foo'); }); } $('.wrapme').wrapAll('<div class="group" />');...

Wrap every 3 divs in a div

Is it possible to use nth-child selectors to wrap 3 divs using .wrapAll. I can't seem to work out the correct equation. so... <div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> becomes... <div> <div class="new"> <div></div> <div></di...

.slice and .wrapall

Hi, I'm using a bit of code suggested by a member on stackoverflow and adapted by me to wrap every 3 li items as part of a mega menu. The code is: var lis = $("ul > li"); for(var i = 0; i < ls.length; i+=3) { lis.slice(i, i+3).wrapAll("<div class='new'></div>"); } Unfortunately this will grab child li's from the next parent menu to ...