Created
November 10, 2015 08:35
-
-
Save jonschr/594e454fa06a4c5cbadf to your computer and use it in GitHub Desktop.
A javascript snippet to wrap just one word with a container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function( $ ) { | |
$('.word-highlight').each(function() { | |
var word = $(this).html(); | |
var index = word.indexOf(' '); | |
if(index == -1) { | |
index = word.length; | |
} | |
$(this).html('<span class="first-word">' + word.substring(0, index) + '</span>' + word.substring(index, word.length)); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment