<span>Result: </span>A long string.CharacterData: replaceData() method / notebook
CharacterData: replaceData() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const span = document.querySelector("span");
const textNode = span.nextSibling;
textNode.replaceData(2, 4, "replaced");