More...
by shatul patil
HTML
<div class="show-more-snippet">
Normally, both your asses would be dead as fucking fried chicken, but you happen to pull this shit while I'm in a transitional period so I don't wanna kill you, I wanna help you. But I can't give you this case, it don't belong to me. Besides, I've already been through too much shit this morning over this case to hand it over to your dumb ass.
</div>
<a href="#" class="show-more">More...</a>
CSS
.show-more-snippet {
height:35px; /*this is set to the height of the how much text you want to show based on the font size, line height, etc*/
width:300px;
overflow:hidden;
}
JavaScript
$('.show-more').click(function() {
if($('.show-more-snippet').css('height') != '35px'){
$('.show-more-snippet').stop().animate({height: '35px'}, 200);
$(this).text('More...');
}else{
$('.show-more-snippet').css({height:'100%'});
var xx = $('.show-more-snippet').height();
$('.show-more-snippet').css({height:'35px'});
$('.show-more-snippet').stop().animate({height: xx}, 400);
// ^^ The above is beacuse you can't animate css to 100% (or any percentage). So I change it to 100%, get the value, change it back, then animate it to the value. If you don't want animation, you can ditch all of it and just leave: $('.show-more-snippet').css({height:'100%'});^^ //
$(this).text('Less...');
}
});