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

前端 未结 14 744
说谎
说谎 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条回答
  •  旧时难觅i
    2020-11-28 22:00

    $('#more').click(function(e) {
        e.stopPropagation();
        $('div').css({
            'height': 'auto'
        })
    });
    
    $(document).click(function() {
        $('div').css({
            'height': '40px'
        })
    })
    

    Check working example at http://jsfiddle.net/7Vv8u/4/

    With Animation http://jsfiddle.net/7Vv8u/5/

    Click on Read more to expand the text. Click outside to minimize it again.

提交回复
热议问题