javascript - 更改 JavaScript 函数以删除 HTML 标记,除了
问题描述
我有以下函数可以消除 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
解决方案
推荐阅读
- asp.net-core - .NET Core 2.1 编辑 cshtml 导致调试期间出错
- fiware - 通过 IOT-Agent Json 修改设备上的属性
- npm - “npm install”和“npm ci”有什么区别?
- ios - SKAction 在 didMovetoview 中有效,但在 Function 中无效
- apache-kafka - Kafka - 消费者/生产者与所有 Zookeper 实例一起工作
- elasticsearch - 带有范围的卷曲的Elastic5查询
- mongodb - 如何在 MongoDB 和 Spring Boot 中过滤文档
- continuous-integration - 我可以在 teamcity 统计选项卡中将测试执行 (Robot FR) 统计作为自定义统计图表吗?
- vba - ScreenUpdating 的值在设置为 False 后没有变化
- jquery - jquery - 为每个产品使用 .each() 一次以插入新价格