SplitTextJS
Light weight Javascript text splitter
This Javascript text splitter has been created to allow easy and seo friendly text splitting (for animations) in two lines of code, it's including words, letters, spaces and special characters splitting.
Example — Repository — Questions
Usage
Download the file and include it in your HTML
This is my cool text!
Or install and import it as a module
$ npm install split-text-js
First, import SplitTextJS :
;
Then, use SplitTextJS :
This is my cool text!
// Select the DOM element wich contains the target textconst text = document; // Split the text and store the resultconst splittedText = text; // Now you can access your splitted text in the returned object // Acces words :const textWords = splittedTextwords; // Acces letters :const textChars = splittedTextchars; // Acces spaces :const textSpaces = splittedTextspaces; // Acces original text :const textOriginal = splittedTextoriginalText;
If everything went well you should see this.