制作一个“;加载更多”;按钮,在我的博客上再显示2篇文章
Make a "Load More" button that shows 2 more articles on my blog
我想制作一个按钮或链接,点击后将显示我存储在索引中的下两个div(文章)。有点像无限滚动滚动滚动效果。这是我所能接近的。要么不显示任何div,要么显示所有div。
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="post-preview">
<a href="post.html">
<h2 class="post-title">
Title
</h2>
<h3 class="post-subtitle">
Description
</h3>
</a>
<p class="post-meta">Posted by <a href="#">Trevor Healy</a> on September 24, 2014</p>
</div>
<hr>
<div class="post-preview">
<a href="post.html">
<h2 class="post-title">
Title
</h2>
<h3 class="post-subtitle">
Description
</h3>
</a>
<p class="post-meta">Posted by <a href="#">Trevor Healy</a> on September 18, 2014</p>
</div>
<!-- Pager -->
<ul class="pager">
<li class="next">
<a href="#" id="load">Older Posts →</a>
</li>
</ul>
<hr>
<div class="post-preview">
<a href="post.html">
<h2 class="post-title">
Title
</h2>
<h3 class="post-subtitle">
Description
</h3>
</a>
<p class="post-meta">Posted by <a href="#">Trevor Healy</a> on August 24, 2014</p>
</div>
<hr>
<div class="post-preview">
<a href="post.html">
<h2 class="post-title">
Title
</h2>
<h3 class="post-subtitle">
Description
</h3>
</a>
<p class="post-meta">Posted by <a href="#">Trevor Healy</a> on July 8, 2014</p>
</div>
<hr>
</div>
</div>
</div>
我有一个css文件,其中存储:
.post-preview { display:none; }
这是我在页面上运行的脚本:
<script>
$(function(){
$(".post-preview").slice(0, 2).show(); // select the first two
$("#load").click(function(e){ // click event for load more
e.preventDefault();
$(".post-preview:hidden").slice(0, 2).show(); // select next two hidden divs and show them
});
});
</script>
内容正确-JQuery库未加载。
相关文章:
- 为什么不't Javascript对我的输入值进行了一些重新检查
- 可以't让我的if语句处理js中的html表单输入
- 我的单元测试选项是什么
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 我的职位回报太快了,如何做出承诺
- 我的jQuery插件参数没有正确启动,遇到了问题
- 如何识别我的网站中的慢速设备
- 如何将JSON数据导入我的ejs模板
- JQuery添加元素需要在我的js之前再次添加JQuery脚本
- 知道为什么我的旋转木马不会自动更改图片吗
- 在我的网站上显示最近提交的文章/图片
- 单击我的joomla网站上的模块标题以指向一篇文章
- 如何让我的wordpress网站在同一页面中显示博客文章,而无需使用AngularJS加载新页面
- 使用 tumblr API(JSON) 和 $.getJSON 从我的 tumblr 博客中获取最新文章
- 我读到了关于javascript函数/原型和(fiddle提供)的文章
- 制作一个“;加载更多”;按钮,在我的博客上再显示2篇文章
- 如何获取我的博客上最后一篇文章的日期,并将其显示在另一个网站上?
- 如何自动保存标题为每一个新的文章提供我的第三方js脚本嵌入在一个网站上
- 我怎样才能使MEAN.js默认的文章用户保存到用户数组中
- 为什么offsetParent忽略我的文章标签