These lines can be long paragraphs, so I'm not sure if it is best to split the entire line with a space delimiter. I am trying to get, say, the first 10 words and wrap them in between:
'<span class="easing">' + string + '</span>'
Then join the second half of the original split. Suggestions for a super efficient way to do this? This will affect no more than three paragraphs per page at a time.
EDITED
Here the kicker - split should occur after the 9th word OR at the end of the first sentence (if this sentence is less than 9 words).
Example
var origString = 'Coming into the world on Elvis' birthday with a doctor named Presley seemed fortuitous until, wielding the silvery smooth scalpel in his aged unsteady hand, the doctor sliced through the walls of my mother's uterus and into my unborn skin. Inside the warm soothing waters of my mother's womb, inside the silent weightlessness, I was safe. Then the prick of cold steel marked the first in a series of rude awakenings. I was scarred for life even before birth.'; var newString = '<span="easing">Coming into the world on Elvis' birthday with a doctor</span> named Presley seemed fortuitous until, wielding the silvery smooth scalpel in his aged unsteady hand, the doctor sliced through the walls of my mother's uterus and into my unborn skin. Inside the warm soothing waters of my mother's womb, inside the silent weightlessness, I was safe. Then the prick of cold steel marked the first in a series of rude awakenings. I was scarred for life even before birth.';
Or with a short sentence starting the paragraph:
var origString = '"Is he okay? Tell me everything's okay" she pleas, her desperate need to confirm my health competing with her own need for consolation.'; var newString = '<span class="easing">"Is he okay?</span> Tell me everything's okay" she pleas, her desperate need to confirm my health competing with her own need for consolation.';
source share