(function($){ $.fn.jTruncate = function(options) { var defaults = { length: 300, minTrail: 20, moreText: " [ + ] more", lessText: " [ - ] less", ellipsisText: "...", moreAni: "", lessAni: "" }; var options = $.extend(defaults, options); return this.each(function() { obj = $(this); var body = obj.html(); if(body.length > options.length + options.minTrail) { var splitLocation = body.indexOf(' ', options.length); if(splitLocation != -1) { // truncate tip var splitLocation = body.indexOf(' ', options.length); var str1 = body.substring(0, splitLocation); var str2 = body.substring(splitLocation, body.length - 1); obj.html(str1 + '' + options.ellipsisText + '' + '' + str2 + ''); obj.find('.truncate_more').css("display", "none"); // insert more link obj.append( // '