selectionStart property

[This documentation is preliminary and is subject to change.]

Gets or sets the starting position or offset of a text selection.

HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 7.6.2Internet Explorer 9

Syntax

HRESULT value = object.put_selectionStart(long v);HRESULT value = object.get_selectionStart(long* p);

Property values

Type: long

The starting position of the text selection.

Standards information

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> 

 

 

Build date: 1/26/2012