layui.use(['table', 'form','layer','laytpl'], function(){ var $ = layui.$,table = layui.table,layer = layui.layer,form = layui.form,laytpl=layui.laytpl,laydate = layui.laydate; laydate.render({ elem: '#temDate', //指定元素 range: '~', type: 'datetime', done: function (value,date,endDate) { var hours = endDate.hours; var minutes = endDate.minutes; var seconds = endDate.seconds; if (hours == "0" && minutes == "0" && seconds == "0"){ $(".layui-laydate-footer [lay-type='datetime'].laydate-btns-time").click(); // 如果是datetime的范围选择,改变开始时间默认值 $(".laydate-main-list-0 .layui-laydate-content li ol li:last-child").click(); // 改变结束时间默认值 $(".laydate-main-list-1 .layui-laydate-content li ol li:last-child").click(); // 如果不是范围选择,只是日期时间选择 $(".laydate-main-list-0 .layui-laydate-content li ol li:last-child").click(); $(".layui-laydate-footer [lay-type='date'].laydate-btns-time").click(); } } }); });