title: How do you get the wider context HTML that wraps a given selector code in jQuery or Cheerio js?
body: <p>How do you get the entire HTML of h1 + ul &gt; li &gt; details &gt; summary + p only if it has that structure? i.e. it wouldn't get the HTML of a ul tag element if it doesn't have a nested li, details etc.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>h1+ul&gt;li&gt;details&gt;summary+p</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;
    &lt;h1&gt;T1&lt;/h1&gt;
    &lt;ul class="toggle"&gt;
      &lt;li&gt;
        &lt;details&gt;
          &lt;summary&gt;&lt;strong&gt;Q1&lt;/strong&gt;&lt;/summary&gt;
          &lt;p&gt;Answer1&lt;/p&gt;
        &lt;/details&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
    &lt;h1&gt;T2&lt;/h1&gt;
    &lt;ul class="toggle"&gt;
      &lt;li&gt;
       &lt;details&gt;
         &lt;summary&gt;Q2&lt;/summary&gt;
         &lt;strong&gt;Answer2&lt;/strong&gt;
       &lt;/details&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>