"more less"
Bootstrap 3.3.0 Snippet by foysal991

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="text-overflow"> Lorem ipsum dolor sit amet, consectetur adipiscing 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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> <a class="btn-overflow" href="#">Show more</a> </div>
.text-overflow { width:250px; height:120px; display:block; overflow:hidden; word-break: break-word; word-wrap: break-word; } .btn-overflow { display: none; text-decoration: none; }
var text = $('.text-overflow'), btn = $('.btn-overflow'), h = text[0].scrollHeight; if(h > 120) { btn.addClass('less'); btn.css('display', 'block'); } btn.click(function(e) { e.stopPropagation(); if (btn.hasClass('less')) { btn.removeClass('less'); btn.addClass('more'); btn.text('Show less'); text.animate({'height': h}); } else { btn.addClass('less'); btn.removeClass('more'); btn.text('Show more'); text.animate({'height': '120px'}); } });

Related: See More


Questions / Comments: