Possible Duplicate:
How Can I Truncate A String In jQuery?
I have this code which allows to display only a certain amount of characters:
$(function(){
$(".description").each(function(i){
len=$(this).text().length;
if(len>10)
{
$(this).text($(this).text().substr(0,260)+'...');
}
});
});
});
The problem is that it doesn't distinguish between words, so it cuts in the middle of the words. What can I do to make it cut only after the last word?