Created
January 7, 2015 14:52
-
-
Save richerimage/70ac6b5f4b34035ad8d9 to your computer and use it in GitHub Desktop.
Add Span Around First Word
This file contains hidden or 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
| <script> | |
| jQuery(function($){ | |
| $.fn.firstWord = function() { | |
| var text = this.text().trim().split(' '); | |
| var first = text.shift(); | |
| this.html((text.length > 0 ? '<span class="title-highlight">'+ first + '</span> ' : first) + text.join(' ')); | |
| }; | |
| $('h1').firstWord(); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment