First, the use of callback done
layui.use('laydate', function() { var 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 The == "0" ) { $ ( ".layui-laydate-footer [Lay-type = 'datetime']. laydate-btns-Time" ). the Click (); // if datetime range selection, the default value change start time $ ( "laydate-main-List-0-laydate .layui OL-Li Li Content:.-Last Child" ) .click (); / / change the end time default value of $ ( "laydate-main-List-1 .layui-laydate Content li-li OL: Last-Child." ) .click (); // if not the scope of choice, but the date and time to select $ ( ".laydate-main-list-0 .layui-laydate-content li ol li: last-child").click(); $(".layui-laydate-footer [lay-type='date'].laydate-btns-time").click(); } } }); });
Callback method can determine if the time is 0 minutes and seconds the object, change the default value of 23:59:59;
Non-range selection:
$(".layui-laydate-footer [lay-type='datetime'].laydate-btns-time").click(); $(".laydate-main-list-0 .layui-laydate-content li ol li:last-child").click(); $(".layui-laydate-footer [lay-type='date'].laydate-btns-time").click();
Range selection:
$(".layui-laydate-footer [lay-type='datetime'].laydate-btns-time").click(); // 改变结束时间默认值 $(".laydate-main-list-1 .layui-laydate-content li ol li:last-child").click(); $(".layui-laydate-footer [lay-type='date'].laydate-btns-time").click();