layui中时间插件laydate的使用
1.加载layui.js
2.html部分
<div class="layui-inline">
<label class="layui-form-label">选择时间</label>
<div class="layui-inline">
<div class="layui-input-inline">
<input type="text" name="start_time" class="layui-input" id="start_time"
placeholder="开始时间">
</div>
</div>-
<div class="layui-inline">
<div class="layui-input-inline">
<input type="text" name="end_time" class="layui-input" id="end_time"
placeholder="结束时间">
</div>
</div>
</div>
3.js部分
layui.use([ 'laydate'], function(){
var $ = layui.$;
var laydate = layui.laydate;
var nowTime = new Date().valueOf();
var start = laydate.render({
elem: '#start_time',
type: 'datetime',
max: nowTime,
btns: ['clear', 'confirm'],
done: function(value, date){
endMax = end.config.max;
end.config.min = date;
end.config.min.month = date.month -1;
}
});
var end = laydate.render({
elem: '#end_time',
type: 'datetime',
max: nowTime,
done: function(value, date){
start.config.max = date;
start.config.max.month = date.month -1;
}
})
})
原文链接:https://blog.csdn.net/qq_21178933/article/details/78581206(感谢分享)