I have the following content DIV on my page, which displays dynamic text:
It uses the following
There is no need to use Javascript to have the ellipsis. You can simply use the CSS text-overflow property and set its value to "ellipsis". You see the documentation here.
text-overflow
And if you want to have it after multiple lines, then advise this guide.