我在一个页面上列出了10条评论。他们的高度是未知的,因为它取决于评论的内容。
最好的方式是只显示第一条评论,直到你点击一个按钮,然后它向下滑动,显示页面中的所有10条评论?因此,默认情况下,用户只会看到一条评论,直到他单击View More Comments按钮,此时它将向下滑动以显示所有评论。
谢谢!
发布于 2010-02-06 02:15:49
jQuery:
$(function(){
$(".comments").not(":first").hide();
$("#btnViewAll").click(function(){
$(".comments").slideDown();
});
});
HTML:
<input type="button" id="btnViewAll" value="Show All Comments" />
<div class="comments">1 comment</div>
<div class="comments">2 comment</div>
<div class="comments">3 comment</div>
<div class="comments">4 comment</div>
<div class="comments">5 comment</div>
发布于 2010-02-06 02:13:06
如果您有一个包含viewMoreButton
类的按钮和一个包含其余注释的包含moreComments
类的div
,那么您可以使用以下脚本:
$("div.moreComments").hide();
$(".viewMoreButton").click(function(){
$("div.moreComments").slideDown("fast");
$(this).remove();
}
它还会删除按钮本身,但如果您希望该按钮切换注释,请执行以下操作:
$("div.moreComments").hide();
$(".viewMoreButton").click(function(){
$("div.moreComments").slideToggle("fast");
}
https://stackoverflow.com/questions/2209316
复制相似问题