Do you have solution to substring text with HTML tags in Javascript?
For example:
var str = \'Lorem ipsum dolor sit
it is solution for single tags
function subStrWithoutBreakingTags(str, start, length) {
var countTags = 0;
var returnString = "";
var writeLetters = 0;
while (!((writeLetters >= length) && (countTags == 0))) {
var letter = str.charAt(start + writeLetters);
if (letter == "<") {
countTags++;
}
if (letter == ">") {
countTags--;
}
returnString += letter;
writeLetters++;
}
return returnString;
}