Reputation: 3126
I need to wrap 3 divs into one using jQuery.
<div class="one"></div><div class="two"></div><div class="three"></div>
into this
<div class="wrap"><div class="one"></div><div class="two"></div><div class="three"></div></div>
How can I do that please?
Many Thanks for your help in advance
Upvotes: 16
Views: 16774
Reputation: 186562
$('.one, .two, .three').wrapAll('<div class="wrap">');
or
$('.one, .two, .three').wrapAll( $('<div>').addClass('wrap') );
Reference: http://docs.jquery.com/Manipulation/wrapAll
Upvotes: 29