HTML DOM deleteFromDocument() method Last Updated : 21 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The deleteFromDocument() method deletes the selected text from the document's DOM tree. Syntax: selectedText.deleteFromDocument() Parameters: No parameters Example: The example deletes the selected text by clicking a button. Upon clicking the button, the Window.getSelection() method gets the selected text, and with the help of the deleteFromDocument() method removes it. HTML <!DOCTYPE html> <html> <head> <title>GeeksforGeeks</title> </head> <body> <h1>GeeksforGeeks</h1> <p> select some text and click on button to delete it from document </p> <button>Click</button> <script> let btn = document.querySelector('button'); btn.addEventListener('click', del); function del() { let sel = window.getSelection(); sel.deleteFromDocument(); } </script> </body> </html> Output: Select some text and then click on the button to delete it from the document. Supported Browsers: Google ChromeEdgeFirefoxOperaSafari Comment More infoAdvertise with us Next Article HTML DOM Table deleteTFoot() Method T taran910 Follow Improve Article Tags : JavaScript HTML-DOM Similar Reads HTML DOM createDocument() Method The DOMImplementation createDocument() method is used to create and return a Document. Syntax: var doc = document.implementation.createDocument(namespaceURI, qualifiedNameStr, docType); parameters: namespaceURI: It is a DOMString containing the namespace URI of the document to be created, or null if 1 min read HTML DOM createHTMLDocument() Method The DOMImplementation createHTMLDocument() method is used to create a new HTML Document. Syntax: newDoc = document.implementation.createHTMLDocument(title); Parameters: title (Optional): It is a DOMString containing the title to be used for the new HTML document. Return Value: This function returns 1 min read HTML DOM createDocumentType() Method The DOMImplementation createDocumentType() method returns a Doctype object which can either be used with DOMImplementation createDocument() method for document creation or can be put into the document. Syntax: var doctype = document.implementation.createDocumentType(qualifiedNameStr, publicId, syste 1 min read HTML DOM Table deleteTFoot() Method The Table deleteTFoot() method is used for deleting a <tfoot> element and its content from a table. It can be only used if a <tfoot> element already exists. SyntaxtableObject.deleteTFoot()Example-1: Deleting an <tfoot> element. html<!DOCTYPE html> <html> <head> 1 min read HTML DOM createDocumentFragment() Method The createDocumentFragment() method in HTML DOM is used to create the document fragment which is useful for changing the content of the document such as deleting, modifying, or adding a new node. This method creates the document fragment, then appends the elements of the document to the document fra 2 min read HTML DOM Range deleteContents() Method The deleteContents() method deletes all the contents of the Range from the Document tree. Syntax: range.deleteContents() Parameters: This method does not accept any parameters. Return value: This method does not return any value. Example: This example describes how to delete the current range from t 1 min read Like