1
这里是我的HTML类:jQuery的去除。点击
<a href="#">Read more</a>
<div class="moreDetails">
<p class="additionalText">Some text help here, random length.</p>
<p class="author">
<span class="bolder"><a href="minidashboard.php?user_url=http://url.people/1332517">Name</a>
</span>
</p>
<div class="replies">
<span>
<a href="topic.php?id=http://url/topics/1049198">1</a>
</span>
</div>
林则使用jQuery类添加到.additionalText
股利时,其文字是超过36个字符长。
的jQuery:
$('.moreDetails p.additionalText').filter(function() {
if ($(this).text().length > 32) {
$(this).addClass('trim');
}
});
时<a href="#">Read more</a>
点击类.trim
被删除,显示的内容我现在想的是。
.trim
将段落设置为固定高度,并将溢出设置为隐藏。
只是仅供参考,我并不是说你的代码不起作用,但它有点奇怪的使用'.filter()'。你可能想用'.each()'来代替。或者使用'.filter()'做更多的事情:'$('。moreDetails p.additionalText')。filter(function(){return $(this).text()。length> 32;})。addClass ( '修剪');' – user113716 2010-08-13 15:11:53