bootstrap-timepicker not working

会有一股神秘感。 提交于 2019-12-24 08:28:06

问题


I am trying to get timepicker to work similarly to datepicker:

    <div class="form-group">
        <div class="input-group date" data-provide="datepicker">
            <input type="text" class="form-control" placeholder="Date *" id="caldate" required data-validation-required-message="Please choose date.">

            <span class="input-group-addon">
                <i class="glyphicon glyphicon-th"></i>
            </span>
            <p class="help-block text-danger"></p>
        </div>
    </div>
    <script>
        var date = new Date();
        date.setDate(date.getDate()+1);
        $('div.input-group.date').datepicker({
            startDate: date
        });
    </script>

    <div class="form-group">
        <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>
            <p class="help-block text-danger"></p>
        </div>
    </div>
    <script type="text/javascript">
        $('#timepicker1').timepicker();
    </script>

Datepicker works, but Timepicker dos not show up when clicked. Did I do something wrong in the javascript part?


回答1:


In head

<link href="css/bootstrap-datepicker3.min.css" rel="stylesheet">
<link href="css/bootstrap-timepicker.min.css"  rel="stylesheet">

In body

    <div class="form-group">
        <div class="input-group date" data-provide="datepicker">
            <input type="text" class="form-control" placeholder="Date *" id="caldate" required data-validation-required-message="Please choose date.">

            <span class="input-group-addon">
                <i class="glyphicon glyphicon-th"></i>
            </span>
            <p class="help-block text-danger"></p>
        </div>
    </div>
    <script>
        var date = new Date();
        date.setDate(date.getDate()+1);
        //    $('div.input-group.date').datepicker({
        $('#caldate').datepicker({
            startDate: date
        });
    </script>

    <div class="form-group">
        <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>
            <p class="help-block text-danger"></p>
        </div>
    </div>
    <script type="text/javascript">
        $('#timepicker1').timepicker({
            defaultTime: 'current',
            minuteStep: 1
        });
    </script>


来源:https://stackoverflow.com/questions/36117489/bootstrap-timepicker-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!