Open In App

HTML DOM Input Number select() Method

Last Updated : 25 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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;">
        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

HTML DOM Input Number select() Method

Supported Browsers:

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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads