I am trying to wrap both a h1
tag and multiple p
tags into one div
using jQuery wrapAll.
Here is my HTML:
<
Try
$('h1').nextUntil('div.img').addBack().wrapAll('<div class="first-col" />');
Demo: Fiddle
Have you tried to just add p inside the selector:
$('.postwrap').each(function(){
$(this).find('h1, p').wrapAll('<div class="first-col" />');
$(this).find('.img').wrapAll('<div class="second-col" />');
});