HTML DOM Input DatetimeLocal step 属性确定秒或毫秒的合法间隔。
句法
以下是语法 -
- 返回数值
inputDatetimeLocalObject.step
- 将step属性设置为数字值
inputDatetimeLocalObject.step = number
参数
参数数值-
价值 | 描述 |
---|---|
秒 | 有效值由完全除以 60 的数字组成(例如:10、15、20) |
毫秒 | 有效值以“.”开头 并完美地划分 1000(例如:.10、.20、.01) |
例子
让我们看一个Input DatetimeLocal 步骤属性的示例 -
<!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>
输出
这将产生以下输出 -
点击“Step Seconds to 10”按钮
单击“步毫秒到 .10”按钮 -