function addmouth(dom,year,month){ !dom.hasClass("amonth")&&dom.addClass("amonth"); var date = new Date(year,month); var tomonth = new Date().getMonth(); var today = new Date().getDate(); var dayhtml = []; var week = ["日","一","二","三","四","五","六"]; dayhtml.push('
<'+date.getFullYear()+'年'+(date.getMonth()+1)+'>
') $.each(week,function(i,v){ dayhtml.push('
'+week[i]+'
') }); var nextdate = new Date(year, month) var firstweek = nextdate.getDay(); //var firstweek = date.getDay(); console.log(date) var first = date.getDate(); var allday = new Date(parseInt(year),(parseInt(month)+1),0).getDate(); //console.log(allday) //console.log(parseInt(year)+","+(parseInt(month)+1)) // console.log(new Date(year,month+1,0)) for(var i = 0;i') }; if (month==tomonth){ for(i=1;i<=allday;i++){ if(i==today){ dayhtml.push('
今天
') } else if(i'+i+'') }else{ dayhtml.push('
'+i+'
') } } }else if(month'+i+'') } }else{ for(i=1;i<=allday;i++){ dayhtml.push('
'+i+'
') } } dom.html(dayhtml.join("")) $(".canday").on("click",function(){ $(".canday").removeClass('placesel'); $(".canday").removeClass('thisday'); // $(this).next().addClass("placesel"); $(this).addClass("thisday"); }) $(".monthleft").unbind(); $(".monthright").unbind(); $(".monthleft").on("click",function(){ var currentdate = $(".currentdate").html(); currentdate = currentdate.split("年"); addmouth($(".month"),currentdate[0],(currentdate[1]-2)); $(".cartime").removeClass("sel") selectDate(); }) $(".monthright").on("click",function(){ var currentdate = $(".currentdate").html(); currentdate = currentdate.split("年"); addmouth($(".month"),currentdate[0],(currentdate[1])); $(".cartime li").removeClass("sel") selectDate(); }) }