A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/Selection/deleteFromDocument below:

deleteFromDocument ยท WebPlatform Docs

deleteFromDocument Summary

Deletes the selected nodes from a document.

Method of dom/Selectiondom/Selection

Syntax
var result = selObj.deleteFromDocument();
Return Value

Returns an object of type NumberNumber

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Examples

In the following example, select the text and elements in the shaded section. When the mouse button is released, the selected items are deleted. Refresh the page to try again.

<!DOCTYPE html>
    <html>
    <head>
    <title>Delete From Document</title>
        <script type="text/javascript">
        function deleteSelectedContent() {
        if (window.getSelection){                       
            var selection = window.getSelection();      
            selection.deleteFromDocument();             
            }
        }
        function refresh()
        {
          window.location.reload( false );              
        }
    </script>
    </head>
    <body>
    <div onmouseup="deleteSelectedContent ()" style="background-color:#c0c0c0;"  >
<h1>Now you see it</h1>
<p>Select some text or elements on this page. When you release the mouse button, it will be gone. </p>
<h2>H2 header</h2>
<p>Some more sample text to <strong>delete</strong>.</p>
</div>
 <input type="button" value="Refresh page" onclick="refresh()"   />
    </body>
</html>
</html>
Syntax

window.getSelection().deleteFromDocument();

Standards information Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4