Skip to content

Instantly share code, notes, and snippets.

@philcon93
Last active June 9, 2016 06:01
Show Gist options
  • Save philcon93/87997231c289f8b88b4d343881fd0b8a to your computer and use it in GitHub Desktop.
Save philcon93/87997231c289f8b88b4d343881fd0b8a to your computer and use it in GitHub Desktop.
Show start of description

Show first few lines in product description

JS

Short the frist few lines in a description and then a 'read more' button. Clicking on this button will show the whole description.

<div class="panel panel-default">
<div id="collapseOne" class="panel-collapse collapse in collapsemob">
<div class="panel-body">
<div class="productdetails ">
<div id="collapslizzle">
<div class="collapslizzle-content">[@description@]</div>
<a class="collapslizzle-btn inactive text-center">
<div class="text-center">Read More <i class="fa fa-plus-square-o"></i></div>
</a>
</div>
</div>
</div>
</div>
</div>
$('.collapslizzle-btn.inactive').click(function(){
$('.collapslizzle-content').toggleClass('active');
$(this)
.toggleClass('active')
.toggleClass('inactive');
if ($(this).hasClass('active')) {
$(this).children('div').html('Hide <i class="fa fa-minus-square-o"></i>');
}else {
$(this).children('div').html('Read More <i class="fa fa-plus-square-o"></i>');
}
});
.collapslizzle-content {
height:65px;
overflow:hidden;
position:relative;
}
.collapslizzle-content.active {
height:100%;
}
.collapslizzle-btn{
margin-top:10px;
display:block;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment