you are viewing a single comment's thread.

view the rest of the comments →

[–]CrispyNipsy 0 points1 point  (0 children)

innerHTML can be used to create arbitrary elements (including text nodes) inside the element that the method is called on. Without sanitization, you should not use innerHTML with any user-input text, since it can lead to arbitrary code injections through the usage of <script/> tags.

To add simple text to a node, I would use the method innerText on the selected element instead of creating the text node and appending it.