You are here: Reference > JavaScript > client-side > HTML DOM > methods > select (input, isindex, textarea)

select method (input, isindex, textarea)

Browser support:
Highlights the entire text in the element.
The selected element automatically gets the focus. A call to the select method fires the onselect and onfocus events.

Syntax:

object.select ( );
You can find the related objects in the Supported by objects section below.

Return value:

This method has no return value.

Example HTML code 1:

This example illustrates the use of the select method:
<head>
    <script type="text/javascript">
        function SelectInput () {
            var input = document.getElementById ("input");
            input.select ();
        }
    </script>
</head>
<body>
    <input type="text" id="input" value="Type here!" />
    <button onclick="SelectInput ()">Select!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content