I need to truncate paragraph text that may or may not include HTML tags. I\'m looking for the most efficient way to do this with straight jQuery or vanilla javascript. You c
If this is for display on a page, a neater way may be to use CSS. Given the HTML:
this is truncated text
and the CSS:
.truncated {
overflow: hidden;
display: block;
width: 50px;
white-space: nowrap;
text-overflow: ellipsis;
}
this will display something similar to:
this is...
You can then use JavaScript to remove the CSS class when required. Sample implementation: http://jsfiddle.net/a8QK4/