html + css + jquery: Toggle Show More/Less Text

后端 未结 5 2057
离开以前
离开以前 2021-01-06 17:05

I\'m working on a personal project and I\'m having a small issue:

This is my code code and currently works: http://jsfiddle.net/gvM3b/:

$(\".show-mor         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-06 18:04

    Update your jQuery:

    $(".show-more").click(function () {
        if($(".text").hasClass("show-more-height")) {
            $(this).text("(Show Less)");
        } else {
            $(this).text("(Show More)");
        }
    
        $(".text").toggleClass("show-more-height");
    });
    

    See http://jsfiddle.net/gvM3b/1/

提交回复
热议问题