我正在寻找使用 javascript 或 jquery 删除尾随 html < br /> 标记的最有效方法的一些想法。
规则:
- 必须删除前端和末端的 br。
- 它必须删除非关闭和自关闭 br 标记。
- 文本内容中的所有 br 都必须保持不变。
的HTML:
<div class="generatedContent">
<br>My awesome content.
<br><br>Some More awesome content.
<br>
<br>
<br>I still need the content written here<br/>
<br>
<br>
<br>
<br>
<br>
<br>
</div>
所需的输出:
<div class="generatedContent">
My awesome content.
<br><br>Some More awesome content.
<br>
<br>
<br>I still need the content written here
</div>