HTML DOM Input DatetimeLocal step 属性

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”按钮 -

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值