.slice & .wrapAll
HTML
<div id="nav">
<p>"Test this theory"</p>
</div>
CSS
.test {
color: red;
}
JavaScript
// wraps last 3 li's of #nav with span that has class .test
var group = $( "p" ).text().slice( 0, 1 );
$(group).wrapAll( "<span class='test' />");