/** * 功能:字符限制 * 作者:wjb * 时间:2019-11-05 */ var w = {}; w.stringevent = function(obj,len){ obj.each(function(){ var maxwidth = len; if($(this).text().length > maxwidth){ $(this).text($(this).text().substring(0,maxwidth)); $(this).text($(this).text() + '…'); } }); };