bootstrap datetimepicker2.3.11时间插件使用
本文实例为大家分享了bootstrapdatetimepicker使用方法,供大家参考,具体内容如下
时间插件之结束时间不能小于开始时间
changeDate:function(starttime,stoptime){//判断时间的大小弹窗提示用户
var_t=this;
if(stoptime!=''&&starttime!=''){
if(stoptime<starttime){
$('#stop-date').val('');
$('#time').modal('show');
setTimeout(function(){($('#time').modal('hide'))},3000);
return;
}
}
},
timeDatapicker:function(){
var_t=this;//this
varstartDate=$('#start-date'),//开始时间
stopDate=$('#stop-date');//结束时间
startDate.datetimepicker({
format:'yyyy-mm-dd',
autoclose:true,
minView:2,
language:'zh-CN'
}).on('change',function(){//changeData方法写在change之后,是为了防止changeData有changge方法(避免冲突)
varstarttime=startDate.val();
varstoptime=stopDate.val();
_t.changeDate(starttime,stoptime);
stopDate.datetimepicker('setStartDate',starttime);//结束时间的选择将以选择的开始时间为依据从新设置(等于开始时间)
}).on('changeDate',function(){
varstarttime=startDate.val();
stopDate.datetimepicker('setStartDate',starttime);//结束时间的选择将以选择的开始时间为依据从新设置(等于开始时间)
varstoptime=stopDate.val();
});
stopDate.datetimepicker({
format:'yyyy-mm-dd',
autoclose:true,
minView:2,
language:'zh-CN'
}).on('change',function(){
varstarttime=startDate.val();
varstoptime=stopDate.val();
_t.changeDate(starttime,stoptime,$(this));
}).on('changeDate',function(){
varstarttime=startDate.val();
varstoptime=stopDate.val();
startDate.datetimepicker('setEndDate',stoptime);
stopDate.datetimepicker('setStartDate',starttime);
});
},
如果大家还想深入学习,可以点击这里进行学习,再为大家附3个精彩的专题:
Bootstrap学习教程
Bootstrap实战教程
Bootstrap插件使用教程
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。