|
-
-
-
-
- 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('<div class="showdate"><span class="monthleft"><</span><span class="currentdate">'+date.getFullYear()+'年'+(date.getMonth()+1)+'</span><span>月</span><span class="monthright">></span></div>')
-
- $.each(week,function(i,v){
- dayhtml.push('<div class="aweek">'+week[i]+'</div>')
- });
- 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<firstweek;i++){
- dayhtml.push('<div class="aday"></div>')
- };
-
- if (month==tomonth){
- for(i=1;i<=allday;i++){
- if(i==today){
- dayhtml.push('<div class="aday canday">今天</div>')
- }
- else if(i<today){
- dayhtml.push('<div class="aday disday">'+i+'</div>')
- }else{
- dayhtml.push('<div class="aday canday">'+i+'</div>')
- }
- }
- }else if(month<tomonth){
- for(i=1;i<=allday;i++){
- dayhtml.push('<div class="aday disday">'+i+'</div>')
- }
- }else{
- for(i=1;i<=allday;i++){
- dayhtml.push('<div class="aday canday">'+i+'</div>')
- }
- }
-
- 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();
-
- })
-
- }
|