Open In App

HTML | DOM Input Time step Property

Last Updated : 07 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The DOM Input Time step Property is used to set or return the value of the step attribute of a number field. The step attribute in HTML is used to specify the legal interval for second and milliseconds in the Time field. The step attribute could be used with min and max attribute for creating a legal value.
For eg. If the value of step attribute is “2” then the legal; number’s will be 0,2,4,6,8 etc.

Syntax:

  • It return the step property.
    timeObject.step
  • It is use to set the step property.
    timeObject.step = number
    • Property Values: It contains a value i.e number Which specify the legal number interval for the Time field.

        For Seconds:

      • Use number “1”, “2”, “10” or “30” when the number of seconds will reach to 60.
      • For milliseconds:

      • It started with (.) and use numbers “.010”, “.050”, “.20” when the number of millisecond will reach to 1000.

      Return Value: It returns a string value which represents the legal number interval for seconds or milliseconds.

      Example-1: This example illustrates how to return the Property.




      <!DOCTYPE html>
      <html>
        
      <head>
          <title>
              DOM Input Time step Property
          </title>
      </head>
        
      <body>
          <center>
              <h1 style="color:green;"
                      GeeksForGeeks 
                  </h1>
        
              <h2>DOM Input Time step Property</h2>
        
              <label for="uname"
                     style="color:green">
                  <b>Enter time</b>
              </label>
        
              <input type="time"
                     id="gfg" 
                     placeholder="Enter time"
                     step="5">
        
              <br>
              <br>
        
              <button type="button"
                      onclick="geeks()">
                  Click
              </button>
        
              <p id="GFG" 
                 style="font-size:24px;
                        color:green'">
            </p>
        
              <script>
                  function geeks() {
                      
                      var link =
                          document.getElementById(
                            "gfg").step;
                      
                      document.getElementById(
                        "GFG").innerHTML = link;
                  }
              </script>
          </center>
      </body>
        
      </html>

      
      

      Output:
      Before Clicking On Button:

      After Clicking On Button :

      Example-2: This Example illustrates how to set the Property.




      <!DOCTYPE html>
      <html>
        
      <head>
          <title>
              DOM Input Time step Property
          </title>
      </head>
        
      <body>
          <center>
              <h1 style="color:green;"
                      GeeksForGeeks 
                  </h1>
        
              <h2>
                DOM Input Time step Property
            </h2>
        
              <label for="uname"
                     style="color:green">
                  <b>Enter time</b>
              </label>
        
              <input type="time" 
                     id="gfg" 
                     placeholder="Enter time" 
                     step="5">
        
              <br>
              <br>
        
              <button type="button"
                      onclick="geeks()">
                  Click
              </button>
        
              <p id="GFG"
                 style="font-size:24px;
                        color:green'">
            </p>
        
              <script>
                  function geeks() {
                      var link =
                          document.getElementById(
                            "gfg").step = "10";
                      
                      document.getElementById(
                        "GFG").innerHTML = 
                        "The value of the step attribute"+
                        " was changed to " + link;
                  }
              </script>
          </center>
      </body>
        
      </html>

      
      

      Output:
      Before Clicking On Button:

      After Clicking On Button:

      Supported Browsers: The browser supported by DOM input Time step Property are listed below:

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


      Like Article
      Suggest improvement
      Share your thoughts in the comments

Similar Reads