Limit characters displayed in span

后端 未结 7 2296
清歌不尽
清歌不尽 2020-12-13 06:36

Is there some sort of way within HTML or CSS to limit the characters displayed with a span? I use a repeater that displays these info boxes and I want to limit the character

7条回答
  •  伪装坚强ぢ
    2020-12-13 07:21

    use js:

     $(document).ready(function ()
       { $(".class-span").each(function(i){
            var len=$(this).text().trim().length;
            if(len>100)
            {
                $(this).text($(this).text().substr(0,100)+'...');
            }
        });
     });
    

提交回复
热议问题