MDN self-hosted library · e01.org

CharacterData: remove() method

DOM

DOM

The remove() method of the CharacterData interface removes the CharacterData node from its parent node. Nothing happens if parentNode is null.

Syntax

remove()

Parameters

None.

Return value

None (undefined).

Example

Using remove()

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

textNode.remove(); // Removes the text

100%

Specifications

Browser compatibility

See also

  • CharacterData.deleteData()
  • DocumentType.remove()
  • Element.remove()