JSFiddle - React, Tailwind, and code Playground
by Matt Ball
HTML
<h1>a</h1>
<p>bla</p>
<p>more bla</p>
<h1>b</h1>
<p>different bla</p>
CSS
div.foo {
margin: 2px;
border: 1px solid #000;
}
JavaScript
var tagName = 'h1';
$(tagName).each(function ()
{
var $this = $(this);
$this.add($this.nextUntil(tagName)).wrapAll('<div class="foo"></div>');
});