HTML DOM中的DOM輸入範圍step屬性用於設置或返回滑塊控件的step屬性的值。 step屬性用於指定兩個值之間的空間大小。此屬性可與min和max一起使用以創建值範圍。
用法:
- 它返回輸入範圍步驟屬性:
rangeObject.step 
- 用於設置“輸入範圍”步長屬性:
rangeObject.step = number 
屬性值:它包含指定步長的單個值數字。步驟的默認值為1。
Return Values:它返回一個數字,代表值之間的增量。
示例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>輸出:
在單擊按鈕之前:

單擊按鈕後:

示例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>輸出:
在單擊按鈕之前:

單擊按鈕後:

支持的瀏覽器:下麵列出了DOM Input Range步驟屬性支持的瀏覽器:
- 穀歌瀏覽器
- IE瀏覽器
- Firefox
- Safari
- Opera
相關用法
- HTML Input Date step用法及代碼示例
- HTML Input DatetimeLocal step用法及代碼示例
- HTML Input Number step用法及代碼示例
- HTML Input Time step用法及代碼示例
- HTML Input Month step用法及代碼示例
- HTML Input Week step用法及代碼示例
- HTML Input Range min用法及代碼示例
- HTML Input Range max用法及代碼示例
- HTML Input Range name用法及代碼示例
- HTML Input Range value用法及代碼示例
- HTML Input Range autofocus用法及代碼示例
- HTML Input Range autocomplete用法及代碼示例
- HTML Input Range form用法及代碼示例
- HTML Input Range type用法及代碼示例
- HTML Input Range disabled用法及代碼示例
注:本文由純淨天空篩選整理自jit_t大神的英文原創作品 HTML | DOM Input Range step Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
