3
I’d like to know how to replace the symbols < />
with Javascript. I’m using the tag <code></code>
to display a code, but I don’t want it to be rendered in the browser. I know I can use <
and >
to display a <tag/> like this, but would like to know if there is a way to make Javascript do it for me, search for the symbols and automatically replace so that the code is not rendered.
I know there are utilities like Syntax Highlighter, but for this case I only need to display the code on a single page and I don’t think it would be interesting to add it to the page.
Have you tried using DOM and Textnode directly?
– luiscubal
@luiscubal, sorry I have not answered before, nor had I noticed your comment... How would I do that you said?
– Wagner'
var textNode = document.createTextNode("Meu código"); codeNode.appendChild(textNode);
– luiscubal