JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
</tr>
</table>
JavaScript
$('td').each(function(idx) {
if (idx % 3) {
return;
} else {
$(this).nextAll(':lt(2)').andSelf().wrapAll('<tr/>');
}
}).parent().unwrap();