Skip to content

Instantly share code, notes, and snippets.

@githubhy
Created March 22, 2016 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save githubhy/69d2a835a43e3c57bdd3 to your computer and use it in GitHub Desktop.
Save githubhy/69d2a835a43e3c57bdd3 to your computer and use it in GitHub Desktop.
Split sentence in HTML
var newText = $( "p" ).text().split( " " ).join( "</span> <span>" );
newText = "<span>" + newText + "</span>";
$( "p" )
.html( newText )
.find( "span" )
.hover(function() {
$( this ).addClass( "hilite" );
}, function() {
$( this ).removeClass( "hilite" );
})
.end()
.find( ":contains('t')" )
.css({
"font-style": "italic",
"font-weight": "bolder"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment