JQuery weui日历只选择3天

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.2/style/weui.min.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.min.css">
    <script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>日历选择</title>
</head>

<body>
    <input type="text" id="mentdate" placeholder="请选择日期">
</body>
<script>
    $(function () {
        var minDate = new Date(new Date().setDate(new Date().getDate() - 1)).format("yyyy-MM-dd");
        var maxDate = new Date(new Date().setDate(new Date().getDate() + 2)).format("yyyy-MM-dd");
        var nowtime = new Date().format("yyyy-MM-dd hh:mm:ss");
        console.log(maxDate)
        console.log(nowtime)
        $("#nowtime").val(nowtime);
        $("#mentdate").calendar({
            title: '预约日期',
            minDate: minDate,
            maxDate: maxDate,
            dateFormat: 'yyyy-mm-dd',
            closeByOutsideClick: true,
            list: []
        })
    })
    Date.prototype.format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1,                 //月份 
            "d+": this.getDate(),                    //日 
            "h+": this.getHours(),                   //小时 
            "m+": this.getMinutes(),                 //分 
            "s+": this.getSeconds(),                 //秒
        };
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        }
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            }
        }
        return fmt;
    }
</script>

</html>

发布了151 篇原创文章 · 获赞 1 · 访问量 2774

猜你喜欢

转载自blog.csdn.net/hql1024/article/details/103732677