Skip to content
Related Articles

Related Articles

HTML DOM Input URL select() Method

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 02 Feb, 2022

The HTML <input type=”url”> is used to define a field that entered a URL. This input value is automatically validated before submitting the form.

The input URL select() method in HTML DOM is used to select the content of a URL text field. It is an in-built method of input URL Object. Refer to components of a URL from the given link

Approach: Blue background color is added to the content of the URL when the user clicks on the button to show that it’s selected.

Syntax:

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

Example: This example uses the input URL select() method to select the content inside the URL Field. 

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>    DOM Input URL select() Method </title>
</head>
  
<body>
    <center>
        <h1 style="color:green;">GeeksforGeeks</h1>
  
        <h2>DOM Input URL select() Method </h2>
  
        <label for="uname"    style="color:green">
            <b>Enter URL</b>
        </label>
  
        <input type="url" id="inputID"    placeholder="Enter URL"
               value="https://www.geeksforgeeks.org/">
        <br>
        <br>
  
        <button type="button" onclick="selectURLMethod()">
            Click
        </button>
  
        <script>
            function selectURLMethod() {
                document.getElementById("inputID").select();
            }
        </script>
    </center>
</body>
</html>

Output:

HTML DOM Input URL select() Method

HTML DOM Input URL select() Method

Supported Browsers: The list of browsers supported by HTML DOM Input URL select() Method are listed below:- 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!