tags:

views:

51

answers:

2

Hi,

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

+3  A: 

http://docs.jquery.com/Manipulation/wrapAll

wildcard
+3  A: 
$('.one, .two, .three').wrapAll('<div class="wrap">');

or

$('.one, .two, .three').wrapAll( $('<div>').addClass('wrap') );

Reference: http://docs.jquery.com/Manipulation/wrapAll

meder
I edited my answer a few times as this was the first time I used jQuery.prototype.wrapAll fyi.
meder
voted you up, for not voting my wrong answer down :)
karim79
oh, someone managed to 1 second before I hit delete. Oh well.
karim79