MDN self-hosted library · e01.org

CharacterData: remove() method

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<span>Result: </span>A long string.
js
const span = document.querySelector("span");
const textNode = span.nextSibling;

textNode.remove(); // Removes the text