How to get a text before given element using jQuery?
<p>Let's consider following html code:</p>

<pre><code>&lt;p&gt;
  Some text followed by &lt;span&gt;a span element&lt;/span&gt;
  and another text followed by &lt;b&gt;a bold text&lt;/b&gt;.
&lt;/p&gt;
</code></pre>

<p>How can I get the text before the <code>span</code> and <code>b</code> elements using jQuery?</p>

<p>I tried <code>$("span").prev()</code> and <code>$("b").prev()</code> but it did work because the text is not an element. I also tried <code>$("span").parent()</code> but it matched whole paragraph, while I want only a part of it.</p>

<p>Could you advise any solution? Thank you in advance :-)</p>
