-2

Having a similar structure:

<div class="container">
    <div class="class1"></div>
    <div class="class2"></div>
    <div class="class3"></div>
    <div class="class4"></div>
</div>

I would like to wrap the last two divs into an other div:

<div class="container">
    <div class="class1"></div>
    <div class="class2"></div>
    <div class="wrapper">
        <div class="class3"></div>
        <div class="class4"></div>
    </div>
</div>
stephjiayi
  • 3
  • 1
  • 1
  • 3
    Welcome to Stack Overflow! We are not here to do your job/homework, so please show us what you tried, and what doesn't work by editing your question! Thanks! – Getz May 05 '14 at 13:13

1 Answers1

-1

Welcome to StackOverflow!

The following should work:

$(".class3, .class4").wrapAll("<div class='wrapper'/>")

.wrapAll() https://api.jquery.com/wrapAll/

EDIT: This would work with jQuery .. sorry didn't notice you were looking for pure javascript ..

rorofromfrance
  • 1,776
  • 11
  • 20