我想在textarea中键入并重新加载highlightjs时突出显示我的代码块和highlight.js
<script>hljs.initHighlighting.called = false;</script>
<pre><code id="demo" class="html"></code></pre>
<textarea style="width:200px;height:200px;" onkeyup="highlighter(this)">
</textarea>
<script>
String.prototype.toHtmlEntities = function() {
return this.replace(/./gm, function(s) {
return "&#" + s.charCodeAt(0) + ";";
});
};
function highlighter(element){
val = element.value;
document.getElementById("demo").innerHTML = val;
hljs.initHighlighting();
}
</script>
但是这部分代码不起作用