【发布时间】:2015-03-02 03:16:08
【问题描述】:
如何只编码 html 标签 ^ "
仅使用 .innerHTML 编码 html 标签
查找 html : & "
替换 html : & "
var Code = document.getElementsByTagName("code");
var charsToReplace = {
'&': '&',
'<': '<',
'>': '>',
'"': '"'
};
Code[0].innerHTML = ?????;
html input:
<code>
<code>
<div><div>
<script></script>
</code>
</code>
html output:
<code>
<code>
<div><div>
<script></script>
</code>
<code>
【问题讨论】:
-
这不是我的答案,只用 innerHTML 编码 html 标签
标签: javascript html innerhtml html-entities