I'm using .innerHTML
to write strings to an HTML page. I need to have things like <
and >
to print alongside <
and >
on the page. However, <
consistently gets printed out as <
. I've heard that I can do this if I write to the page as HTML rather than text, but I thought .innerHTML
was doing that. Is there an escape character I can use or is there something I can do with JS to get this done?
Asked
Active
Viewed 471 times
1

Jackson Egan
- 2,715
- 4
- 18
- 26
-
2Have you tried `document.write()`? Also, `&` – David Feb 13 '13 at 17:19
-
1@gordon He looks to be trying to go in the other direction. – Jackson Egan Feb 13 '13 at 17:39
2 Answers
1
You can use <pre><</pre>
and <pre>&rt;</pre>
tags in your HTML
output .. This should give you the output you are looking for.

Zak
- 6,976
- 2
- 26
- 48
-
This just added a line between the < and the tag it should surround. – Jackson Egan Feb 13 '13 at 17:23
-
I would suggest posting more code then so that we all may have a better grasp of what you are attempting to do. – Zak Feb 13 '13 at 17:28
-
-
1