【发布时间】:2020-07-18 07:52:21
【问题描述】:
我有以下函数可以消除html代码的所有标记:
function saringtags(r, l) {
for (var e = r.split("<"), n = 0; n < e.length; n++) - 1 != e[n].indexOf(">") && (e[n] = e[n].substring(e[n].indexOf(">") + 1, e[n].length));
return e = e.join(""), e = e.substring(0, l - 1)
}
问题是这样的:
<div class="lyric">
<blockquote>
It's nine o'clock on a Saturday<br>
The regular crowd shuffles in<br>
There's an old man sitting next to me<br>
Makin' love to his tonic and gin<br>
</blockquote>
</div>
变成这样:
It's nine o'clock on a SaturdayThe regular crowd shuffles inThere's an old man sitting next to meMakin' love to his tonic and gin
如何为函数中的<br> 标记创建异常?
这个结果就是我需要的:
It's nine o'clock on a Saturday<br>The regular crowd shuffles in<br>There's an old man sitting next to me<br>Makin' love to his tonic and gin
【问题讨论】:
-
首先将所有
<br>替换为\n?
标签: javascript html