Reputation: 1576
I have this code
<div class="superdiv">
<div></div>
<div></div>
</div>
I want to wrap all .superdiv
children divs into a div called <div class="subdiv"></div>
How can I make that ?
Thanks
Upvotes: 1
Views: 26
Reputation: 28445
Try following
$(".superdiv > div").wrapAll("<div class='subdiv'/>");
Upvotes: 0
Reputation: 240868
You could use the .wrapInner()
method:
$('.superdiv').wrapInner('<div class="subdiv"></div>');
You could also use the .wrapAll()
method on the children elements:
$('.superdiv').children().wrapAll('<div class="subdiv"></div>');
Upvotes: 2