This page is Not Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

selectionStart

Property of dom/HTMLInputElementdom/HTMLInputElement

Syntax

var result = element.selectionStart;
element.selectionStart = value;

Examples

The following code example shows how to set a text selection’s start and end positions.

<!DOCTYPE html>
<html>
<head>
<title>Selection Start and End example</title>
    <script>
        function SelectSomeText () {
            var input = document.getElementById ("Textbox");
                input.selectionStart = 4;
                input.selectionEnd = 13;
        }
    </script>
</head>
<body>
    <p><input type="text" id="Textbox" size="40" value="The text selection appears here"/></p>
    <p><button onclick="SelectSomeText ()">See selection</button></p>

</body>
</html>

Syntax

Standards information

See also

Related pages

Attributions