HTML | DOM Input Time step Property

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 nnuber 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.

      filter_none

      edit
      close

      play_arrow

      link
      brightness_4
      code

      <!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>

      chevron_right

      
      

      Output:
      Before Clicking On Button:

      After Clicking On Button :

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

      filter_none

      edit
      close

      play_arrow

      link
      brightness_4
      code

      <!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>

      chevron_right

      
      

      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


      My Personal Notes arrow_drop_up

      Check out this Author's contributed articles.

      If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

      Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



      Improved By : shubham_singh



      Article Tags :
      Practice Tags :


      Be the First to upvote.


      Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.