HTML DOM Input Number select() Method

The Input Number select() Method in HTML DOM is used to select the contents of the Input Number field. it is the in-built method of the Number Object. 

Syntax

numberObject.select()

Parameters: This method does not contain any parameters.

Return Value: This method does not return any value.

Example: Below HTML code illustrate the use of input number select() method in HTML DOM .  

HTML




<!DOCTYPE html>
<html>
<body style="text-align:center;">
    <h1 style="color:green;">
        w3wiki
    </h1>
    <h2>DOM Input Number select() Method</h2>
    <form id="myBeginner">
        <input type="number" value="152356537838"
            id="myNumber" step="5" name="Beginner"
            autofocus>
    </form>
    <br><br>
    <button onclick="myFunction()">
        Click Here!
    </button>
    <script>
        function myFunction() {
 
            // Select the content of a Input Number field
            var x = document.getElementById(
                    "myNumber").select();
        }
    </script>
</body>
</html>


Output:

HTML DOM Input Number select() Method

Supported Browsers:

  • Google Chrome
  • Edge 12 and above
  • Firefox
  • Safari
  • Opera