Horje
HTML DOM Input Search select() Method

The Input Search select() Method in HTML DOM is used to select the content of the Input search text field. It is the predefined method of the Search object. 

Syntax:

searchObject.select()
  • Parameters: It does not accept any parameter.
  • Return Value: It does not return any value.

Example: This example uses the Input Search select() method to select the content inside the search field.   

HTML

<!DOCTYPE html>
<html>
 
<head>
    <style>
        h1 {
            color: green;
        }
 
        body {
            text-align: center;
        }
    </style>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h2>Input Search select() Method</h2>
 
    <input type="Search" id="test"
           placeholder="Type to search.."
           value="GeeksForGeeks">
    <br>
    <br>
    <br>
    <button onclick="selectContent()">
      Select the Content of Search Field
    </button>
 
    <script>
        function selectContent() {
           
            // Use the select() method
            document.getElementById(
                "test"
            ).select();
        }
    </script>
</body>
 
</html>

Output:

Supported Browsers:

  • Google Chrome 5 and above
  • Edge 12 and above
  • Firefox 4 and above
  • Safari 5 and above
  • Opera 10.6 and above



Reffered: https://www.geeksforgeeks.org


HTML

Related
HTML DOM Input Range defaultValue Property HTML DOM Input Range defaultValue Property
HTML &lt;menuitem&gt; type Attribute HTML &lt;menuitem&gt; type Attribute
HTML DOM Input Week select() Method HTML DOM Input Week select() Method
How to create 3D cube using canvas in HTML5 ? How to create 3D cube using canvas in HTML5 ?
HTML Geolocation clearWatch() Method HTML Geolocation clearWatch() Method

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
12