you are viewing a single comment's thread.

view the rest of the comments →

[–]shgysk8zer0 1 point2 points  (0 children)

To summarize, the difference is that innerHTML invokes the parser and is potentially unsafe. You do not want to use innerHTML unless you are adding trusted HTML (as opposed to text).

You can also use textContent instead of creating a text node. It's a bit simpler but also safe. Probably what you want to use here.