Javascript text splitter for easy and seo friendly animations, allows text, word, spaces and special characters splitting.
npm install split-text-jsSplitTextJS
===========
[![NPM package][npm]][npm-url]
#### 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
Download the file and include it in your HTML This is my cool text!
``html
`
-----------
Or install and import it as a module
`sh`
$ npm install split-text-js
First, import _SplitTextJS_ :
`javascript`
import SplitTextJS from 'split-text-js';
Then, use _SplitTextJS_ :
` This is my cool text!html`
`javascript
// Select the DOM element wich contains the target text
const text = document.querySelector('.text');
// Split the text and store the result
const splittedText = new SplitTextJS(text);
// Now you can access your splitted text in the returned object
// Acces words :
const textWords = splittedText.words;
// Acces letters :
const textChars = splittedText.chars;
// Acces spaces :
const textSpaces = splittedText.spaces;
// Acces original text :
const textOriginal = splittedText.originalText;
``
If everything went well you should see this.
[npm]: https://img.shields.io/npm/v/split-text-js.svg
[npm-url]: https://www.npmjs.com/package/split-text-js