-1

我从这里下载了时间选择器。在剪切了很多代码之后,我来到了这个简单的例子:

<html>
    <head>
        <title>jQuery.timepickr.js</title>
        <link rel="Stylesheet" media="screen" href="reset.css" />
        <link rel="Stylesheet" media="screen" href="styles.css" />
        <link rel="Stylesheet" media="screen" href="../dist/themes/default/ui.core.css" />
        <link rel="Stylesheet" media="screen" href="../src/css/ui.timepickr.css" />
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.js"></script>
        <script type="text/javascript" src="jquery.utils.js"></script>
        <script type="text/javascript" src="jquery.strings.js"></script>
        <script type="text/javascript" src="jquery.anchorHandler.js"></script>
        <script type="text/javascript" src="jquery.ui.all.js"></script>
        <script type="text/javascript" src="../src/ui.timepickr.js"></script>


        <script type="text/javascript">
            $(function(){
              $('#timepicker').timepickr().focus();
              $('#timepicker').next().find('ol').show().find('li:eq(2)').mouseover();
            });
        </script>
    </head>
    <body id="themeroller">

        <div id="splash">
            <div id="demo">
                <div id="d-demo-wrapper-1" class="demo-wrapper">
                    <input id="timepicker" type="text" value="02:30" class="demo">
                </div>

            </div>
        </div>
    </body>
</html>

我注意到,当我尝试从键盘手动设置时间时,数字会自动更改,然后鼠标不在输入字段中。我注意到即使在原始示例中我也无法手动设置数字。我该如何解决这个问题?

4

1 回答 1

1

您可以设置默认值,通过使用val属性timepickr

$("#timepickr").timepickr({
            convention: 12,
            format12: "{h:02.d}:{m:02.d} {z:s}",
            rangeMin: $.range(0, 60),
            val: "02:00 am" //set your default time here
        });
于 2012-12-03T11:23:13.653 回答