Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM Input Range step Property

  • Difficulty Level : Basic
  • Last Updated : 29 Mar, 2019
Geek Week

The DOM Input Range step Property in HTML DOM is used to set or return the value of the step attribute of the slider control. The step attribute is used to specify the size of space between two values. This attribute can be used with both min and max to create a range of values.

Syntax:

  • It returns the Input Range step Property:
    rangeObject.step
  • It is used to set Input Range step Property:
    rangeObject.step = number

Property Values: It contains single value number which specify the size of steps. The default value of steps is 1.

Return Values: It return a number which represents the increment between values.

Example-1:






<!DOCTYPE html>
<html>
  
<head>
    <title>
        DOM Input Range step Property
    </title>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;"
            GeeksForGeeks 
        </h1>
  
    <h2>
      DOM Input Range step Property
  </h2>
  
    <input type="range" 
           id="myRange"
           step="15">
  
    <br>
    <br>
  
    <button onclick="myGeeks()">
        Click Here!
    </button>
  
    <p id="GFG" 
       style="font-size:23px;
              color:green;">
  </p>
  
    <script>
        function myGeeks() {
  
            // Accessing input value 
            var x =
                document.getElementById(
                  "myRange").step;
            
            document.getElementById(
              "GFG").innerHTML = x;
        }
    </script>
  
</body>
  
</html>

Output:
Before Click on button:

After Click on button:

Example-2:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        DOM Input Range step Property
    </title>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;"
            GeeksForGeeks 
        </h1>
  
    <h2>
      DOM Input Range step Property
  </h2>
  
    <input type="range"
           id="myRange"
           step="15">
  
    <br>
    <br>
  
    <button onclick="myGeeks()">
        Click Here!
    </button>
  
    <p id="GFG" 
       style="font-size:23px;
              color:green;">
  </p>
  
    <script>
        function myGeeks() {
  
            // Accessing input value  
            var x =
                document.getElementById(
                  "myRange").step = "25";
  
            document.getElementById(
              "GFG").innerHTML =
                "The value of the step attribute"+
              " was changed to " + x;
        }
    </script>
  
</body>
  
</html>

Output:
Before Click on button:

After Click on button:

Supported Browsers: The browser supported by DOM Input Range step Property are listed below:

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

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :