I came across lots of Question regarding this , and i found solution for PHP only. There was no solution on this site for jQuery/javascript way of doing it.
What I want to do is I want to show first 100 characters but I dont want to cut the last word, as it would be meaningless.
Like say this is myself
is the last words so it we regularly take substring and y
is 100th word, then it would cut it like this is my
, which would be meaning less. So I want it like this is..
My original code :
jQuery(".block-text .success-inner-content").each(function(){
if(jQuery(this).text().length > 100){
jQuery(this).text(jQuery(this).text().substr(0,98)+'..');
}
});
here block-text .success-inner-content
class is in loop producing list of Divs with text within it.