Use unwrap
and wrap
:
var toMove = $('.move-me');
toMove.children().unwrap();
$('.container').wrap(toMove);
UPDATE: please note that the code above won't work if the form has nested raw text. You could wrap the form's children with another tag for it to work (also using end
as pointed out by Yoshi in the comments):
$('.container').wrap(
$('.move-me').wrapInner('<div class="nostyle"/>').children().unwrap().end()
);