I use substr()
on a string to output a set of characters from a message. My problem is that if the string contains HTML I would get the tags in the text.
Is it possible to parse the HTML before using substr()
to only extract the text from the message itself?
Example 1:
var string = "Hi";
alert(string.substr(0, 7));
Alert:
Hi
Example 2:
var string = "<br/>Hi";
alert(string.substr(0, 7));
Alert:
<br/>Hi