首页 > 解决方案 > 如何在 html 中添加加载更多按钮

问题描述

我正在尝试在我的 django 网站上创建一个加载更多帖子按钮。我希望首先显示 10 个帖子,然后在每 10 个帖子之后出现加载更多按钮,一次加载 10 个帖子。如果没有更多帖子要加载,我还希望加载更多按钮消失。使用下面的代码。

        {% for act in acts %}
                <div class="blog-item">
                    <div class="bi-pic">
                        <img src="{{act.image.url}}" alt="{{act.alt}} height="320" width="320"">
                    </div>
                    <div class="bi-text">
                        <div class="label">Article</div>
                        <ul></ul>
                        <div class="fp-text">
                           <h3>{{act.title}}</h3>
                        </div>
                        <ul>
                            <li>by <span>{{act.writter}}</span></li>
                            <li>{{act.date}}</li>
                            <li>20 Comment</li>
                        </ul>
                        <p>{{act.article | truncatechars:248}}
                        </p>
                        <div class="load-more-btn">
                          <a href="{{act.slug}}">read more</a>
                        </div> 
                    </div>
                </div>
               {% endfor %}

标签: pythonhtmlloopsfor-loopdjango-templates

解决方案


推荐阅读