HTML DOM 輸入日期時間區域性 step 屬性
HTML DOM 輸入日期時間區域性 step 屬性決定秒或毫秒的合法間隔。
語法
語法如下所示 −
- 返回數值
inputDatetimeLocalObject.step
- 將 step 屬性設定為數值
inputDatetimeLocalObject.step = number
引數
引數 number 值 −
| 值 | 說明 |
|---|---|
| 秒 | 有效值由能夠完美除以 60 的數字構成(例如:10、15、20) |
| 毫秒 | 有效值以“.”開頭,並能夠完美除以 1000(例如:.10、.20、.01) |
示例
讓我們看一個 Input DatetimeLocal step 屬性的示例 −
<!DOCTYPE html>
<html>
<head>
<title>Input DatetimeLocal step</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Datetime-Local-step</legend>
<label for="datetimeLocalSelect">Local Date Time :
<input type="datetime-local" id="datetimeLocalSelect" step="2">
</label>
<input type="button" onclick="changeStep('10')" value="Step Seconds to 10">
<input type="button" onclick="changeStep('.10')" value="Step milliseconds to .10">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputDatetimeLocal = document.getElementById("datetimeLocalSelect");
function changeStep(myStep) {
inputDatetimeLocal.step = myStep;
if(inputDatetimeLocal.step.indexOf('.') === -1)
divDisplay.textContent = 'Seconds step: '+inputDatetimeLocal.step;
else
divDisplay.textContent = 'Milli-seconds step: '+inputDatetimeLocal.step;
}
</script>
</body>
</html>輸出
這將生成以下輸出 −
單擊 “秒步長為 10” 按鈕

單擊 “毫秒步長為 .10” 按鈕 −

廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP