Skip to content

Instantly share code, notes, and snippets.

@Waidoss
Created August 9, 2018 15:22
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 Waidoss/a5ad59e51c4d961969541f3b65fb1608 to your computer and use it in GitHub Desktop.
Save Waidoss/a5ad59e51c4d961969541f3b65fb1608 to your computer and use it in GitHub Desktop.
Split text and wrap to span all word
// 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