<div id="divA">This is <span>some</span> text!</div>Node: textContent property / notebook
Node: textContent property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
let text = document.getElementById("divA").textContent;
// The text variable is now: 'This is some text!'document.getElementById("divA").textContent = "This text is different!";
// The HTML for divA is now:
// <div id="divA">This text is different!</div>