我使用 Google Code Prettify 语法高亮我的代码。这是我的 HTML
<head>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
</head>
<body>
<div id ="xmlView">
<pre class="prettyprint">
<code class="language-xml" id="xmlTextArea"></code>
</pre>
</div>
</body>
当直接在 HTML 中将代码添加到 xmlTextArea 并将所有 < 和 > 替换为 > 和 < 时,它就可以了,但在使用 jquery 设置代码时却不是这样:
$('#xmlTextArea').text(code)
PR.prettyPrint()
之后我也试着打电话