截取元素中文字的长度,多余的显示...

    function ellipsis(obj, num) {
        obj.each(function() {
            var maxwidth = num;
            if($(this).text().length > maxwidth) {
                $(this).text($(this).text().substring(0, maxwidth) + '......');
            }
        });
    }
    ellipsis($(".Row4_news_text h5"), 50);

  

posted @ 2020-04-17 18:00  可达鸭给我冲鸭  阅读(143)  评论(0编辑  收藏  举报