DOM
The remove() method of the CharacterData interface removes the CharacterData node from its parent node. Nothing happens if Node.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
Example
Specifications
Browser compatibility
See also
- CharacterData.deleteData()
- DocumentType.remove()
- Element.remove()
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
