Making of text shorter or to minimize sometimes becomes necessary to get a better design.I'm going to share how to make it shorter using Jquery and Javascript,but you must know the basic of Jquery to work with it so lets start with it.
For instance your post is having structure something like this one<div class='post'>So to make it short a we use
Ea eam labores imperdiet, apeirian democritum ei nam, doming neglegentur ad vis. Ne malorum ceteros feugait quo, ius ea liber offendit placerat, est habemus aliquyam legendos id. Eam no corpora maluisset definitiones, eam mucius malorum id. Quo ea idque commodo utroque, per ex eros etiam accumsan.
Eu mei solum oporteat eleifend, libris nominavi maiestatis duo at, quod dissentiet vel te. Legere prompta impedit id eum. Te soleat vocibus luptatum sed, augue dicta populo est ad, et consul diceret officiis duo. Et duo primis nostrum.
</div>
.substr
function which extract a particular part of a text.So we do something like this one.$('.post').each(function(){Now the result will be
var text=$(this).text();
var count=100;
if(text.length>count){
var cut=text.substr(0,count);
}
else{
var cut=text;
}
$(this).html(cut+"...");
});
Image Credit:smashingmagazine.com
Post A Comment:
0 comments: