если конкретно обрезать "Как обрезать многострочный текст"
(function($) {
'use strict';
$.fn.succinct = function(options) {
var settings = $.extend({
size: 240,
omission: '...',
ignore: true
}, options);
return this.each(function() {
var textDefault,
textTruncated,
elements = $(this),
regex = /[!-\/:-@\[-`{-~]$/,
init = function() {
elements.each(function() {
textDefault = $(this).html();
if (textDefault.length > settings.size) {
textTruncated = $.trim(textDefault)
.substring(0, settings.size)
.split(' ')
.slice(0, -1)
.join(' ');
if (settings.ignore) {
textTruncated = textTruncated.replace(regex, '');
}
$(this).html(textTruncated + settings.omission);
}
});
};
init();
});
};
})(jQuery);
$(function() {
"use strict";
$('.truncate299').succinct({
size: 299,
omission: '...',
ignore: true
});
$('.truncate200').succinct({
size: 200,
omission: '...',
ignore: true
});
$('.truncate100').succinct({
size: 100,
omission: '...',
ignore: true
});
$('.truncate80').succinct({
size: 80,
omission: '...',
ignore: true
});
$('.truncate25').succinct({
size: 25,
omission: '!',
ignore: true
});
$('.truncate20').succinct({
size: 20,
omission: '',
ignore: true
});
});