Open In App

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 .  




<!DOCTYPE html>
<html>
<body style="text-align:center;">
    <h1 style="color:green;">
        GeeksForGeeks
    </h1>
    <h2>DOM Input Number select() Method</h2>
    <form id="myGeeks">
        <input type="number" value="152356537838"
            id="myNumber" step="5" name="geeks"
            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:

Article Tags :