I am using the jQuery dotdotdot truncation plugin dotdotdot.frebsite.nl
I want to truncate at max 2 lines. And when a user clicks on more, then it must show the full text (expand/de-truncate).
So far, I "only" manage to truncate my text. But not to "de-truncate" it.
Here is my code:
<p class="truncate">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vitae tellus eu dui placerat interdum. Lorem ipsum dolor sit amet, consectetur adipiscing elit.<a class="read-more" href="#">more</a></p> $(document).ready(function(){ $('.truncate').dotdotdot({ ellipsis : '… ', watch : true, wrap : 'letter', height : parseInt( $('.truncate').css('line-height'), 10) * 2, // this is the number of lines lastCharacter: { remove: [ ' ', ',', ';', '.', '!', '?' ], noEllipsis: [] }, after: "a.read-more" }); }); Live demo jsfiddle.net/NSnxe/1
lastCharacteroption are the same as the default ones. Hence this part of the code is irrelevant.