CharacterData: remove() Methode
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since Juli 2015.
Die remove()
-Methode von CharacterData
entfernt das Element von seinem Elternknoten. Wenn es keinen Elternknoten hat, bewirkt ein Aufruf von remove()
nichts.
Syntax
js
remove()
Parameter
Keine.
Rückgabewert
Keine (undefined
).
Beispiel
>Verwendung von remove()
html
<span>Result: </span>A long string.
js
const span = document.querySelector("span");
const textNode = span.nextSibling;
textNode.remove(); // Removes the text
Spezifikationen
Specification |
---|
DOM> # ref-for-dom-childnode-remove①> |
Browser-Kompatibilität
Loading…