Substring text with html tags in javascript
Posted
by
honzahommer
on Stack Overflow
See other posts from Stack Overflow
or by honzahommer
Published on 2011-05-14T16:43:32Z
Indexed on
2012/11/07
11:01 UTC
Read the original article
Hit count: 221
Do you have solution to substring text with html tags in Javascipt? For example:
var str = 'Lorem ipsum <a href="#">dolor <strong>sit</strong> amet</a>, consectetur adipiscing elit.'
html_substr(str, 20)
// return Lorem ipsum <a href="#">dolor <strong>si</strong></a>
html_substr(str, 30)
// return Lorem ipsum <a href="#">dolor <strong>sit</strong> amet</a>, co
© Stack Overflow or respective owner