Here is html :
<div class="wrapper">
<div class="small">
<p>Lorenter code hereem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div> <a href="#">Click to read more</a>
Here is css :
.small {
height: 20px;
overflow:hidden;
}
.big {
height: auto;
}
Here is javascript :
$('.wrapper').find('a[href="#"]').on('click', function (e) {
e.preventDefault();
this.expand = !this.expand;
$(this).text(this.expand?"Click to collapse":"Click to read more");
$(this).closest('.wrapper').find('.small, .big').toggleClass('small big');
});
the problem is it always show the click for expand although some of my text( which genarate from php nevermind that) is really short and dont need that readmore function
so pls anyone can come up with some height condition so that they dont display the click to read more when the text is under certain height
Here is a sample FIDDLE : http://jsfiddle.net/mWcmg/302/
already have a look at jedfoster and counter same problem and i don't really have enough time to analyze that
– TuanAnh Aug 04 '15 at 16:38