简体   繁体   English

时间类型的html输入元素可以具有默认值吗?

[英]Can an html input element with a type of time have a default value?

Should the following code work to set a default time? 以下代码可以设置默认时间吗? If not, is there a way to make it work strictly with html and no Javascript? 如果没有,是否有办法使它严格与html一起使用而没有Javascript?

<input type="time" name="time" id="whatever" value="1:10">

When I manually set a time to the widget and use document.getElementById("whatever").value to output the value I get a string that uses military time to denote am/pm. 当我手动为窗口小部件设置时间并使用document.getElementById(“ whatever”)。value输出值时,我得到一个字符串,该字符串使用军事时间表示am / pm。

Thank you. 谢谢。

You need to use HH:MM format, so: 您需要使用HH:MM格式,因此:

<input type="time" name="time" id="whatever" value="13:10">

for 1PM or: 1PM或:

<input type="time" name="time" id="whatever" value="01:10">

for 1AM . 1AM

Demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM