The deleteData() method of the CharacterData interface removes all or part of the data from this CharacterData node.
deleteData(offset, count)offsetThe number of bytes from the start of the data to remove from. 0 is the first character of the string.
countThe number of bytes to remove.
None.
IndexSizeError DOMExceptionThrown if offset is greater than the length of the contained data.
<span>Result: </span>A long string.const span = document.querySelector("span");
const textNode = span.nextSibling;
textNode.deleteData(1, 5);