效果图:
**
实现方式:
**
1.引入插件
插件下载(网盘)https://pan.baidu.com/s/19MI2r6zCVV2iH8U4jy0Yqw
2.html或jsp中引入
<script type="text/javascript" src="${ctx}/resources/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.fr.js"></script>
<script type="text/javascript" src="${ctx}/resources/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<link href="${ctx}/resources/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css" rel="stylesheet">
<script src="${ctx}/resources/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
3.input代码
<input style="width:60px;display: inline-block;margin-top: 5px" type="text"
name="showStartTime"
placeholder="开始时间" readonly/>
至
<input style="width:60px;display: inline-block;margin-top: 5px" type="text"
name="showEndTime"
placeholder="结束时间" readonly/>
4.js代码
$(function(){
//初始化
$("input[name='showStartTime']").each(function (index, domEle) {
$(domEle).datetimepicker({
format: 'hh:ii',
autoclose: 1,
todayHighlight: 1,
startView: 1,
minView: 0,
minuteStep: 1,
forceParse: 1
});
var date = $(domEle).val();
$(domEle).val(date.substr(10));
});
$("input[name='showEndTime']").each(function (index, domEle) {
$(domEle).datetimepicker({
format: 'hh:ii',
autoclose: 1,
todayHighlight: 1,
startView: 1,
minView: 0,
minuteStep: 1,
forceParse: 1
});
var date = $(domEle).val();
$(domEle).val(date.substr(10));
});
});