I have cms that allows users to embed content blocks on a page. Various types of content are available to the user, and they can be inserted in any order. An example of a high-level dom structure might look something like this:
<p>Some rich text</p> <div class="box">...</div> <div class="box">...</div> <div class="box">...</div> <h3>Some more rich text</h3> <p>Lorem ipsum</p> <div class="box">...</div> <div class="box">...</div>
What I want to do is wrap any adjacent βsideβ divs in a wrap container div. Thus, in the above example, two βcontainersβ of divs would be added, since there are two div div groups, resulting in:
<p>Some rich text</p> <div class="container"> <div class="box">...</div> <div class="box">...</div> <div class="box">...</div> </div> <h3>Some more rich text</h3> <p>Lorem ipsum</p> <div class="container"> <div class="box">...</div> <div class="box">...</div> </div>
I donβt think there is an efficient way to do this with css selectors, so does anybody know about this with jQuery anyway?
source share