Range: deleteContents() method

The Range.deleteContents() method removes the contents of the Range from the Document.

Unlike Range.extractContents(), this method does not return a DocumentFragment containing the deleted content.

Syntax

js
deleteContents()

Parameters

None.

Return value

None (undefined).

Examples

js
range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
range.deleteContents();

Specifications

Specification
DOM Standard
# dom-range-deletecontents

Browser compatibility

desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
deleteContents

See also