我想做一个按钮或链接,当点击时,将显示下两个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>发布于 2015-11-11 03:43:32
内容正确-未加载JQuery库。
https://stackoverflow.com/questions/33602239
复制相似问题