Find the number of lines in a div

后端 未结 3 953
醉酒成梦
醉酒成梦 2021-01-07 23:14

I want to show \'View All\' kind of link, only when the lines in the div has reached 4 lines.

HTML

3PAS-Pub-IO-doubl
3条回答
  •  庸人自扰
    2021-01-08 00:20

    You can use the ThreeDots plugin for jQuery: http://tpgblog.com/2009/12/21/threedots-the-jquery-ellipsis-plugin/

    When calling ThreeDots() on your

    , set max_rows to 4. Just look at the examples on that page, you can also set your custom "read more" link. But beware that you have to wrap your text into an extra , like so:

    your text

    ... the jQuery code line would then be:

    $('.text_here').ThreeDots({ max_rows:4 });
    

提交回复
热议问题