JSFiddle - React, Tailwind, and code Playground

HTML

<body>
<div>other stuff</div>
<div>
<div>Start</div>
<table><tbody><tr><td>Oops</td></tr></tbody></table>
</div>
<div>
<div>End</div>
</div>
<p>other stuff</p>
</body>

JavaScript

$(function() {
    var $elie = $("div:contains(Start)").eq(0), htmlArr = [];
    htmlArr.push($('<div>').append( $elie.clone() ).html());        
    while($elie.find("div:contains(End)").length != 1) {
        $elie = $elie.next();       
        htmlArr.push($('<div>').append( $elie.clone() ).html());
    };
    // htmlArr now has the HTML
    // let's see what it is:
    alert(htmlArr.join(""));
});