有一段字符:
test
testg,想判断内容长度(不包含html标签)是不是大于5,如果大于5就显示test
t...显示,替换的只是内容,不是html标签,这个js怎么写?[code="java"]
var str2 = "
test
testg"; result=result+c;
if(c=='<') {
beginElement = true;
continue;
}
if(c=='>') {
beginElement=false;
continue;
}
if(beginElement) {
continue;
}
if(++count>=max) {
break;
}
}
if(count+1 < length) {
result = result + "...";
}
alert(result);
[/code]
不是非常精准,但够了