Getting text before element
<p>How could I get the text of the body that is before a specific element using Javascript/jQuery?
What I want to achieve is finding out the position of an element respect of the body, for instance, if the body text is 100 characters long and the text before the node is 50, that node would be at 50%.
Getting body's length is easy, but getting the text before an element is not as trivial as I'd thought in first instance.</p>

<p>EDIT:</p>

<p>To make it clear, I'll give an example:</p>

<pre><code>&lt;body&gt;
   &lt;p&gt;
      ...some text &lt;span&gt;that could have sub-elements&lt;/span&gt;
   &lt;/p&gt;
   &lt;p&gt;
      ...some text
      &lt;ul&gt;
         &lt;li&gt;now with a list&lt;/li&gt;
         &lt;li&gt;why not?&lt;/li&gt;
      &lt;/ul&gt;
   &lt;/p&gt;
   &lt;div&gt;
      &lt;p&gt;...some text...&lt;/p&gt;
      &lt;div&gt;
          &lt;p&gt;...some text...&lt;/p&gt;
          &lt;p id="this_is_the_element"&gt;what's there in the body before this element?&lt;/p&gt;
          &lt;p&gt;...some text...&lt;/p&gt;
          &lt;p&gt;...some text...&lt;/p&gt;
      &lt;/div
   &lt;/div&gt;
&lt;/body&gt;
</code></pre>

<p>In this case, the specific node would be <code>#this_is_the_element</code> and what I would expect to get is something like:</p>

<pre><code>...some text that could have sub-elements 
...some text 
now with a list 
why not? 
...some text 
...some text
</code></pre>
