* { margin:0; padding:0; } body { font-family:"Microsoft YaHei","微软雅黑"; font-size:16px; } .clear:after { content:" "; display:block; height:0; visibility:hidden; clear:both; } ul { list-style:none; } .wrap { width:100%; margin:0 auto; } .wrap-main { width:80%; margin:0 auto; padding-top:50px; } .wrap-main>table { width:100%; margin:0 auto; text-align:center; line-height:40px; cursor:pointer; border-color:#cccccc; } .wrap-main .list,.wrap-main .list>ul { width:100%; margin:0 auto; } .wrap-main .list { padding-top:50px; } .wrap-main .list>ul>li { width:80%; margin:0 auto; padding-top:20px; } .wrap-main .list>ul>li:nth-child(3) div { margin-left:100px; line-height:40px; } .wrap-main .list>ul>li:nth-child(3) div label { width:30%; display:inline-block; } .wrap-main .list>ul>li>span { display:inline-block; width:100px; line-height:40px; } .wrap-main .list>ul>li>select { width:70%; height:40px; border:1px solid #cccccc; border-radius:3px; font-size:16px; font-family:"Microsoft YaHei","微软雅黑"; text-indent:10px; } .wrap-main .list>ul>li>select>option { line-height:30px; border:1px solid #cccccc; } .wrap-main .list>ul>li>input { width:70%; line-height:39px; border:1px solid #cccccc; border-radius:3px; font-size:16px; font-family:"Microsoft YaHei","微软雅黑"; text-indent:10px; } .wrap-main .list>ul>li>button { line-height:40px; font-family:"Microsoft YaHei","微软雅黑"; font-size:16px; width:150px; outline:none; background-color:#1e9be8; border-radius:5px; color:#ffffff; margin-left:40%; margin-top:5%; } .active { background-color:#7fceff; color:white; }
1、先获取当前日期:
var currDT; var aryDay = new Array("日", "一", "二", "三", "四", "五", "六"); //显示星期 var lastDay; //页面显示的最后一天var firstDay;//页面显示的第一天 var date = new Date; //获取完整日期 var year = date.getFullYear(); //获取当前年份
2、 获取当前一周日期:
//初始化日期加载 function initDate() { currDT = new Date(); showdate.innerHTML = currDT.toLocaleDateString(); //显示日期 var dw = currDT.getDay(); //从Date对象返回一周中的某一天(0~6) var tdDT; //日期 //在表格中显示一周的日期 var objTB = document.getElementById("mytable"); //取得表格对象 for (var i = 0; i < 7; i++) { tdDT = getDays()[i]; dw = tdDT.getDay(); //星期几 objTB.rows[0].cells[i].innerHTML = tdDT.getMonth() + 1 + "月" + tdDT.getDate() + "日 星期" + aryDay[dw]; //显示 var newtime = '<input type="text" value="' + year + "-" + (tdDT.getMonth() + 1) + "-" + tdDT.getDate() + '">'; $(".newtime").append(newtime); if (tdDT.toLocaleDateString() == currDT.toLocaleDateString()) { objTB.rows[0].cells[i].style.color = "white"; //currDT突出显示 objTB.rows[0].cells[i].style.backgroundColor = "#1e9be8"; //currDT突出显示 $(".datetime").find("input").val($(".newtime").find("input").eq(i).val()) // alert($(".newtime").find("input").eq(i).val()) } } //重新赋值 lastDay = getDays()[6]; //本周的最后一天 firstDay = getDays()[0]; //本周的第一天 }