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/collapseToEnd below:

collapseToEnd ยท WebPlatform Docs

collapseToEnd Summary

Collapses or sets the insertion point or caret at the end of a selection object.

If the content the selection is in is focused and editable, the caret will blink there.

Method of dom/Selectiondom/Selection

Syntax
var result = selObj.collapseToEnd();
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

The following code example puts the caret or insertion point at the end of the selected text.

<!DOCTYPE html>
<html>
<head>
   <title>Collapse to Start Example</title>
    <script>
        function SelectAtEnd () {
            if (window.getSelection) {
                var selection = window.getSelection ();
                selection.collapseToEnd ();
            }
        }
    </script>
</head>
<body>
<p>
    <div contenteditable="true" style="width:300px;">
        Select some text from this paragraph, and then click the following button.
        When you click the button, the caret, or insertion point, is set to the end of your selection.
    </div>
 </p>
 <p><input type="button" name="test" value="Set caret" onclick="SelectAtEnd ()" /> </p>
</body>
</html>
Notes Remarks

Raises an INVALID_STATE DOMException if there are no Ranges in the selection.

Syntax

selObj.collapseToEnd()

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