javascript-text-truncate
v3.0.0
Published
Truncate text in elements
Downloads
5
Maintainers
Readme
JavaScriptTextTruncate
An amazingly small, dependency-less utility for text truncation. Less than 1 KByte!
Download
# Get it with npm ...
$ npm i javascript-text-truncate
# Or clone it from GitHub
$ git clone https://github.com/PascaleBeier/JavaScriptTextTruncate
Usage
<div class="truncate">
Est soluta rerum velit quasi quos et esse. Velit dolore quis autem distinctio dolor molestiae placeat. Rerum est magni quae et quo non voluptatem exercitationem. Molestiae et voluptas perferendis deserunt velit voluptatem. Earum quo consequuntur velit tempore cum nihil sint omnis.
Soluta est vel sed id molestiae recusandae non. In harum minima aut pariatur quam eligendi dolores. Consequatur quod deleniti adipisci corporis totam. Non autem rerum iusto vero accusantium numquam nesciunt sequi.
</div>
Browser Global
<script src="javascript-text-truncate.min.js"></script>
<script>
truncate({
el: '.truncate',
length: 255,
seperator: 'Read More ...'
});
</script>
ES6
import * as truncate from 'javascript-text-truncate'
truncate({
el: '.truncate',
length: 255,
seperator: 'Read More ...'
})
Options
truncate({
el: '.truncate', // Element containg text to be truncated. Defaults to null.
length: 255, // Truncate text after the given amount of charakters. Defaults to 255.
seperator: 'Read More ...' // Text to be placed after the truncated text. Defaults to 'Read More ...'
})
CHANGELOG
See CHANGELOG.
LICENSE
See LICENSE.