Created
August 9, 2018 15:22
-
-
Save Waidoss/a5ad59e51c4d961969541f3b65fb1608 to your computer and use it in GitHub Desktop.
Split text and wrap to span all word
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
// Page index, split description text for gsap "staggerFrom" | |
var text = $('#design').text(), | |
splitSpace = text.split(' '), | |
wordsArray = []; | |
counter = 1; | |
$(splitSpace).each(function(i){ | |
markup = '<span class="span-'+ counter +'"> ' + splitSpace[i] + ' </span>'; | |
wordsArray.push(markup); | |
counter += 1; | |
}); | |
var finalArray = wordsArray.join(' '); | |
$('#design').html(finalArray); | |
about = $('#design span'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment