Here is my html:
<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>
Im then using jQuery to add a class to the .additionalText div when its text is longer than 36 chars.
jQuery:
$('.moreDetails p.additionalText').filter(function () {
if ($(this).text().length > 32) {
$(this).addClass('trim');
}
});
What I now want is when <a href="#">Read more</a> is clicked the class .trim to be removed and reveal the content.
.trim sets the paragraph to a fixed height with overflow set to hidden.
.filter(). You probably want to use.each()instead. Or with.filter()do something more like this:$('.moreDetails p.additionalText').filter(function () { return $(this).text().length > 32; }).addClass('trim');