Range.deleteContents()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.

Range.deleteContents() 移除来自 DocumentRange 内容。

不像Range.extractContents一样,本方法不会返回一个包含删除内容的文本片段DocumentFragment

语法

range.deleteContents()

例子

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

规范

Specification
DOM Standard
# dom-range-deletecontents

浏览器兼容性

BCD tables only load in the browser

参考