This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

deleteContents

Summary

Removes all contents within a selected range.

Method of dom/Rangedom/Range

Syntax

var object = object.deleteContents();

Return Value

Returns an object of type NumberNumber

Type: HRESULT

This method can return one of these values.

Return codeDescription
S_OKThe operation completed successfully.
InvalidStateErrordetach has been invoked on the object.
W3Exception_DOM_NO_MODIFICATION_ALLOWED_ERRSome of the contents or nodes are read-only.

Examples

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

Notes

Remarks

If the deleted range contains closing or opening tags, the remaining tags are completed.

Syntax

Range.deleteContents();

Standards information

Related specifications

DOM
Living Standard

Attributions