I have this code which I can't directly modify:
<div id="registerMessage">
<div class="pageTitle" style="padding:0px 0px 5px 0px;">
Register
</div>
Some bla bla bla
</div>
<input type="hidden" name="ardir" value="" />
<input name="action" type="hidden" value="insert" />
<label>Email </label>
<div>
<input name="user[email]" id="user[email]" type="text" value="" size="35" class="inputReg" />
</div>
<label>Password (5 chars)</label>
<div>
<input name="user[passwd]" type="password" value="" size="35" class="inputReg" />
</div>
<label>Password (confirm)</label>
<div>
<input name="user[password_confirm]" type="password" value="" size="35" class="inputReg" />
</div>
<div id="memomessage">
(Other bla bla bal)
</div>
I need to wrap from the first label to the last div
(memomessage excluded) into a new div
:
<div id="registerBox"> the code of before </div>
$('label:first').nextAll().andSelf().not('#memomessage').wrapAll('<div id="registerBox">')
Here's a fiddle