I have paragraph that has a read more link nested in it.
<p>Lorem ipsum blah blah blah <a href="link">Read More</a></p>
I need to truncate the paragraph text and end it with an ellipsis without affecting anything in the <a></a>
tag.
I can do the truncation of the text using $(p).text($(p).text().substring(0,n)+'...');
but of course if I grab the paragraph using $(p).text()
it would include the link and would lop it off.
Is there a way to grab, and then replace with the truncated version, the text of the <p>
without affecting the </a>
. Preferably without having to use any regex or having to clone the link and re-append it?