问题
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