How can I select with jQuery the first two words in a sentence, wrap them with a span tag and add a br tag after it?
Something like this:
<p><span>Lorem ipsum</span><br/> quosque tandem</p>
But add the span and br tag dynamically.
I can only do that for the first word with this code:
$('p').each(function(){
var featureTitle = $(this);
featureTitle.html( featureTitle.text().replace(/(^\w+)/,'<span>$1</span><br/>') );
});
Thanks!!