JavaScript · DOM and events
textContent
Reads or writes text safely. The browser escapes it, so it cannot inject markup.
Syntax
el.textContent = "…"Example
Try it
Notes
Prefer textContent over innerHTML for any value that came from a user.
More in this group
Learn this in the course
Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.