【问题标题】:html - How to show input time show M:S.ms (minutes:second.milisecond)?html - 如何显示输入时间显示 M:S.ms (minutes:second.millisecond)?
【发布时间】:2018-04-09 07:20:37
【问题描述】:

如何在html中输入时间?

我希望输入的格式是 MM:SS.ms。

我想像https://www.olympic.org/pyeongchang-2018/results/en/alpine-skiing/results-men-s-downhill-trno-000100-.htm那样制作时间表

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>

【问题讨论】:

标签: javascript html time


【解决方案1】:
<input id=foo name=foo type=time min="0:00" max="120:00">

https://jsfiddle.net/tz35nqso/

我知道 HTML5 有一个输入时间元素,但您必须删除毫秒字段。否则,请像其他人建议的那样使用 3rd 方库。

【讨论】:

    猜你喜欢
    • 2023-03-27
    • 2020-05-31
    • 1970-01-01
    • 2020-01-30
    • 2013-11-12
    • 2018-10-20
    • 1970-01-01
    • 2019-10-05
    • 1970-01-01
    相关资源
    最近更新 更多