How to trim HTML encoded text without trimming encoded characters using javascript
I need to write some client side javascript for a web page that truncates the text inside the div when the onclick event for the button fires (the purpose of the button is to allow users to toggle the displayed text between full and truncated versions). There will be no HTML tags in the text, but there may be HTML-encoded characters such as "and &
Do you have this which is better than having to decode the HTML string, trim and encode again?
It seems like it might be a fairly common task that was done earlier. I'm not that good with JavaScript, so I don't know if there is a better way to do this with javascript than encoding / decoding.
0
a source to share