How to hide/show more text within a certain length (like youtube)

前端 未结 14 736
说谎
说谎 2020-11-28 21:24

I want to have a text to only be a certain amount of characters/length and after that length, I want to put a link to reveal the full length of the text.

The link w

14条回答
  •  醉酒成梦
    2020-11-28 22:23

    The secret about this effect, is wrapping the parts that you want to control with HTML tags.

    $(".more").toggle(function(){
        $(this).text("less..").siblings(".complete").show();    
    }, function(){
        $(this).text("more..").siblings(".complete").hide();    
    });
    

    text goes here
    
     this is the 
    complete text being shown
    
    more...
    

    Online demo here: http://jsfiddle.net/zA23k/215/

提交回复
热议问题