How do I wrap the innerhtml found after a span in a paragraph inside a span. Better explained by example:
<p>foo <span>bar</span> baz</p>
I want to get:
<p>foo <span>bar</span><span> baz</span></p>
baz is possible marked up as well (ie can contain links etc).
Ive tried
$(p span).first().contents().filter(function() {
return this.nodeType == 3;
}).text();
But only gives me the inner span text of first span…
DEMO