Last active
August 2, 2018 07:38
-
-
Save andreyshr/80b0a41ce4d0ee384f62cc668aa10f9b to your computer and use it in GitHub Desktop.
sliceText(textNodes, symbols)
This file contains hidden or 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
function sliceText(textNodes, symbols) { | |
textNodes.forEach(cur => { | |
const text = cur.innerText; | |
let sliced = text.slice(0,symbols); | |
if (sliced.length < text.length) { | |
sliced += '...'; | |
cur.innerText = sliced; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment