Reputation: 13850
I have a div-element that I want to show the symbol '<'.
div-element.innerHMTL = '<';
The string actually do not appears, I think the problem lies in that the browser thinks that it is a beginning of a tag element
Anyone seen this problem before?
Upvotes: 3
Views: 760
Reputation: 21563
You should use an HTML entity - <
. This will be displayed by the browser as <, rather than being interpreted as the start of an HTML tag.
Here's a handy list of common HTML entities: http://www.danshort.com/HTMLentities/
Upvotes: 5
Reputation: 15835
This might be useful link which shows all symbols http://www.w3schools.com/HTML/html_entities.asp
Upvotes: 1
Reputation: 8381
You should use innerText when you just want to set text or you should encode the text when you want to mix html with text
Upvotes: 1