Bootstrap timepicker没有出现

时间:2017-02-18 23:14:42

标签: timepicker bootstrap-timepicker

我的前端有以下代码。我无法让时间戳显示出来。有什么帮助吗?

<!DOCTYPE HTML>
<html>
  <head>
 <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-timepicker/0.5.2/js/bootstrap-timepicker.js"></script>

  <link type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-timepicker/0.5.2/css/bootstrap-timepicker.min.css" />

<script type="text/javascript">
  $(() => {
    $('#timepicker1').timepicker();
  });
</script>     

  </head>
  <body>
         <div class="input-group bootstrap-timepicker timepicker">
            <input id="timepicker1" type="text" class="form-control input-small">
            <span class="input-group-addon"><i class="glyphicon glyphicon-time"></i></span>
        </div>

  </body>
<html>

我在上面的代码中提到的正确路径中包含了所有必需的源文件。此外,我没有在浏览器日志中看到任何错误。请帮我解决这个问题。

谢谢大家

编辑:我现在使用jsfiddle中提供的所有源文件的直接cdn链接。

2 个答案:

答案 0 :(得分:0)

在bootstrap上使用时间选择器。您必须使用datetimepicker组件。并使用format属性仅允许捕获小时和分钟

<!DOCTYPE HTML>
<html>
<head>
    <link href="bootstrap-3.3.7/css/bootstrap.css" rel="stylesheet">
    <link href="bootstrap-3.3.7/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <script src="bootstrap-3.3.7/js/jquery-1.11.3.min.js"></script>
    <script src="bootstrap-3.3.7/js/moment.js"></script>
    <script src="bootstrap-3.3.7/js/bootstrap.js"></script>
    <script src="bootstrap-3.3.7/js/bootstrap-datetimepicker.min.js"</script>
    <script src="bootstrap-3.3.7/js/transition.js"></script>
    <script src="bootstrap-3.3.7/js/collapse.js"></script>

</head>
<body>
    <div class="input-group bootstrap-timepicker timepicker">
        <input id="timepicker1" type="text" class="form-control input-small">
        <span class="input-group-addon"><i class="glyphicon glyphicon-time"></i></span>
    </div>

    <script type="text/javascript">
    $(function () {
        $('#timepicker1').datetimepicker({
             format: 'HH:mm'
        });

    });
    </script>
</body>
<html>

答案 1 :(得分:0)

的rel =&#34;样式表&#34;其中一个css标签丢失了。那就是问题。