时间 ‹input type='time'›

isixe 2020-06-06 18:15:15
Categories: Tags:

 

属性

说明

value

包含输入到输入中的时间值

max

表示接受的最晚时间的字符串,以与上述相同的时间值格式指定。如果指定的字符串不是有效时间,则不设置最大值。

min

一个字符串,指定接受的最早时间,以前面描述的时间值格式给出。如果指定的值不是有效的时间字符串,则不设置最小值。

readonly

一个布尔属性,如果存在,则表示该字段不能由用户编辑

step

对于时间输入,step 的值以秒为单位,比例因子为 1000(因为基础数值以毫秒为单位)。 step 的默认值为 60,表示 60 秒(或 1 分钟,或 60,000 毫秒)。

示例

<!DOCTYPE html>

<html lang="en">

 

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

 

<body>

    <form>

        <label for="appt-time">Choose an appointment time: </label>

        <input id="appt-time" type="time" name="appt-time">

    </form>

</body>

 

</html>

 

浏览器运行结果如下:

 

 

来自 <https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input/time>