我不知道什么是错我的代码:阅读更多/读少
$(document).ready(function(){
var adjustheight = 80;
var moreText = "+ read more";
var lessText = "- less text";
$("div.posted_post .more-block").css('height', adjustheight).css('overflow', 'hidden');
$("div.posted_post").append('[...]');
$("a.show").text(moreText);
$(".show").toggle(function()
{
$(this).find(".more-block").css('height', 'auto').css('overflow', 'visible');
$(this).text(lessText);
}, function(){
$(this).find(".more-block").css('height', adjustheight).css('overflow', 'hidden');
$(this).text(moreText);
});
});
的HTML如下:
<div class="posted_post">
<div class="more-block">
<p>The Content</p>
<a class="show"></a>
</div>
</div>
当我加载页面的显示更多按钮显示,但在第二个它隐藏什么是错的?
你的HTML缺少a.show部分。另外,我对$(this).find(“。more-block”)非常困惑,这表明a.show吞没了整个模块 – jbl 2013-02-19 10:29:12
不能理解你到底想要做什么。如果你提供更多的信息(比如身体标签数据),效果会更好 – 2013-02-19 10:30:25
有些CSS会对更多的html有帮助。我认为这可能是一个CSS问题。 – Hendeca 2013-02-19 10:33:01