Selection.deleteFromDocument()

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

备注: The Selection.deleteFromDocument() method deletes the actual text being represented by a selection object from the document's DOM.

Syntax

sel.deleteFromDocument()

Parameters

None.

Examples

A user selects the (imaginary) text "ve two ea" from "Rabbits have two ears." on a web page. The user then clicks a button that executes the JavaScript snippet window.getSelection().deleteFromDocument(). The document's text becomes "Rabbits hars."

Specifications

Specification
Selection API
# dom-selection-deletefromdocument

Browser compatibility

BCD tables only load in the browser

See also