/*----------------------------- slice_str_limit -----------------------------*/ (function($){ var defaults = { overLengthStr:'...' }; $.fn.sliceStrLimit = function(options){ var configs = {}, el = this, lenEl = el.length, limitLength, str, funcInit = function(){ configs = $.extend({}, defaults, options); str = el.text().trim(); limitLength = el.data('slice_str_limit'); el.funcExecute(); }; if(lenEl === 0)return this; if(lenEl > 1){ el.each(function(){$(this).sliceStrLimit(options)}); return this; } el.funcExecute = function(){ el.html(str.slice(0, limitLength) + (limitLength < str.length?configs.overLengthStr:'')); }; funcInit(); }; })(jQuery); /*----------------------------- /slice_str_limit -----------------------------*/