JSFiddle - React, Tailwind, and code Playground

by lollero

HTML

<h2>title</h2>
<div>normal text</div>
<h2>title</h2>
<div>normal text</div>
<h2>title</h2>
<div>normal text</div>

CSS

.parent { border: 1px dashed red; }

JavaScript

$(document).ready(function() {
  $('h2').each(function() {
    $(this).next().andSelf().wrapAll('<div class="parent" />');
  });
});