title: How do I get the previous HTML text prior to a node?
body: <p>UPDATE:<br>
  Someone asked: <em>for what purpose would I want to do this?</em><br>
  I'm trying to get the string index of a selected node server side, and since I have to account for repetition of small selections / nodes, I figure getting all html prior to the selected node on the client side would help in being the most accurate way to get the index.</p>
  
  <p>lets say I have html like this:</p>
  
  <pre><code>&lt;tag&gt;
     &lt;child&gt;
        &lt;subchild&gt;
        &lt;/subchild&gt;
     &lt;/child&gt;
  &lt;/tag&gt;
  </code></pre>
  
  <p>and I "select" subchild.
  I want to get all preceeding HTML as text** prior to that node.. so, in this case that would be:</p>
  
  <pre><code>&lt;tag&gt;
     &lt;child&gt;
  </code></pre>
  
  <p>is there a slick, easy way to do that?</p>
  
  <p>** I specify "as text" because, using jQuery / modern browsers, incomplete tags would become valid, as jQuery tries to make sure things don't break. Since I would not doing DOM manipulation with this information, I don't need valid HTML syntax.</p>