How do i get text of an element in html?
ExamplesReturn the text content of an element: Show
let text = element.textContent; Try it Yourself » Change the textual content of a element with id="demo": element.textContent = "I have changed!"; Try it Yourself » Get all the textual content of an
let text = document.getElementById("myList").textContent; Try it Yourself » Definition and UsageThe The Differences Between innerHTML, innerText and textContentSee below SyntaxReturn the text content of a node: or Set the text content of a node: element.textContent = text Property Value
Return Value
The Differences Between innerHTML, innerText and textContent
|