<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8" /> <title>Title</title> <link rel="stylesheet" href="layui-master/dist/css/layui.css" /> <style> #f1 { width: 500px; margin: 500px auto; } </style> </head> <body> <div> <form action="" class="layui-form" id="f1"> <input type="text" id="i1" /> </form> </div> <script src="layui-master/dist/layui.js"></script> <script> layui.use(['laydate', 'layer'], () => { var $ = layui.$ var laydate = layui.laydate laydate.render({ elem: '#i1', //指定元素 type: 'datetime', min: '2021-1-15', max: '2021-2-18', /*重点代码*/ ready() { $('.layui-laydate-content table tbody tr').on( 'click', 'td', function () { if ( $(this).attr('class') == '' || $(this).attr('class') == null || $(this).attr('class') == 'layui-this' ) { $( ".layui-laydate-footer [lay-type='datetime'].laydate-btns-time" ).click() } } ) } }) }) </script> </body></html>