JS限制内容显示多少个字符

    //$(".comment_txt").each(function(){
           var len=$('#text').text().length;
           if(len>75){
               var str="";
               str=$('#text').text().substr(0,75)+"…<span>全文</span>";//限制75个字符
               $('#text').html(str);
           }
        //});
        $(".comment_txt_box span").each(function(){
            $(this).click(function(){
                $(this).parent('.comment_txt_box').next().show();
                $(this).parent('.comment_txt_box').remove();
            })
        });
原文地址:https://www.cnblogs.com/wangyongx/p/15188949.html