如何在博主上添加“加载更多”按钮

How to add "load more" button on blogger?

本文关键字:加载 加载更多 按钮 添加      更新时间:2023-09-26

我想在博主页面上添加一个"加载更多"按钮。我找到了这个示例.但是我不知道把代码的每一部分放在blogger(HTML/CSS/JavaScript)的什么位置,尤其是jQuery部分的代码。

$(function(){
    $("div").slice(0, 10).show(); // select the first ten
    $("#load").click(function(e){ // click event for load more
        e.preventDefault();
        $("div:hidden").slice(0, 10).show(); // select next 10 hidden divs and show them
        if($("div:hidden").length == 0){ // check if any hidden divs still exist
            alert("No more divs"); // alert if there are none left
        }
    });
});

我找到了一个解决方案,这段代码就是我想要的

    <div>content content content content content content content content content content content content content content content.<a href="javascript:void(0);" onclick="jQuery('.show-more-toggle').toggle();" class="show-more-toggle v5-dark-link">show more</a><span class="show-more-toggle" style="display: none">more more more more more more more more more more more more more more more more more </span></div>