我如何在html中输入时间?
我希望输入的格式是MM:SS.ms。
中制作时间表MM: minutes
SS: second
ms: milisecond
这是我到目前为止所做的事情
<style type="text/css">
#time1, #time2 {
width: 125px;
}
</style>
<form>
<label for="time1">Result </label>
<input id="time1" type="text" name="time1">
<input type="checkbox" onclick="enableInputTime('time1')"> Input Time?
<br>
<label for="time2">Result </label>
<input id="time2" type="text" name="time2">
<input type="checkbox" onclick="enableInputTime('time2')"> Input Time?
</form>
<script type="text/javascript">
function enableInputTime(id) {
var id = document.getElementById(id);
if(id.type === 'text') {
id.type = 'time';
id.step = "0.1";
} else {
id.type = 'text';
id.list = "Options";
}
}
</script>
答案 0 :(得分:1)
<input id=foo name=foo type=time min="0:00" max="120:00">
https://jsfiddle.net/tz35nqso/
我知道HTML5有一个输入时间元素,但您必须删除毫秒字段。否则请使用第三方库,就像其他人建议的那样。