Is there any JavaScript Library to intelligently truncate strings?
- by j0ker
I need to truncate strings in a side menu to make the fit into a div without a linebreak. The divs have a fixed width. I'm looking for a library to do that for me.
If a string is too long to fit into the div, it should be truncated like:
<div>This string is too long</div> == <div>This string is...ong</div>
As you can see, the string is not only truncated by an ellipsis but the last three letters are also visible. This is meant to increase readability. The truncation should not care about spaces.
Does anyone know of a library that includes such functionality? We're mainly using jQuery throughout the project.
Thanks in advance!