textContent
noun
say it: “TEKST KON-tent” /tɛkst ˈkɒntɛnt/
An element's text as plain text; setting it replaces what the element shows.
What is textContent in JavaScript?
textContent — An element's text as plain text. Setting it replaces everything inside the element with that text, and any < in it is shown as a character, never read as HTML, which makes it the safe choice for text users typed.
const count = document.getElementById("cart-count");
count.textContent = 3;
In a sentence
- “I set the badge's textContent to 3 after adding to the cart.”
Level: Apprentice · More JavaScript terms at this level
Updated