• jQuery联动日历(三)完成


    一、要实现的功能:

      1.点击上面的箭头,切换至上一个月,或下一个月,并且是联动的。

      2.只要不是现实中的当月,那么显示的日期,都是灰色底。

    二、分析:

      1.当我们点击切换日期的箭头时,要改变顶部蓝色的年份和日期。

      2.当我们点击切换日期的箭头时,下面TD的日期也要和上面显示的月份对应起来。

      3.用一个判断,是否现实中的当月,来控制TD的背景色,是否为灰色

     

    DEMO下载

    //点击更新前一个月
        $(".pre").live("click",function(){
            nowTitleDateM--;
            if(nowTitleDateM == 11){
                    nowLastM = nowTitleDateM-1
                    nextTitleDateY--
                    nextTitleDateM = nowTitleDateM+1
                    nextLastM = 1
            }else if(nowTitleDateM == 0){
                    nowTitleDateY--
                    nowTitleDateM = 12;
                    nowLastM = nowTitleDateM-1;
                    nextTitleDateM = 1;
                    nextLastM = nextTitleDateM+1
            }else if(nowTitleDateM == 1){
                    nowLastM = 12;
                    nextTitleDateM = nowTitleDateM+1
                    nextLastM = nextTitleDateM+1
            }else{
                    nowLastM = nowTitleDateM-1
                    nextTitleDateM = nowTitleDateM+1
                    nextLastM = nextTitleDateM+1
            }
                
            //天数和存放位置
            update();
            
            //插入到日期数的TD当中                    
            insertTd();
            
            //更新日期标题
            updateTitle();
    
        })
    //点击下一个月
    $(".next").live("click",function(){ nowTitleDateM++; if(nowTitleDateM == 12){ nowLastM = nowTitleDateM-1 nextTitleDateY++ nextTitleDateM = 1 nextLastM = nextTitleDateM+1 }else if(nowTitleDateM == 11){ nowLastM = nowTitleDateM-1 nextTitleDateM = nowTitleDateM+1 nextLastM = 1 }else if(nowTitleDateM == 13){ nowTitleDateY++ nowTitleDateM = 1; nowLastM = 12; nextTitleDateM = nowTitleDateM+1; nextLastM = nextTitleDateM+1 }else if(nowTitleDateM == 1){ nowLastM = 12; nextTitleDateM = nowTitleDateM+1 nextLastM = nextTitleDateM+1 }else{ nowLastM = nowTitleDateM-1 nextTitleDateM = nowTitleDateM+1 nextLastM = nextTitleDateM+1 } //天数和存放位置 update(); //插入到日期数的TD当中 insertTd(); //更新日期标题 updateTitle(); })
  • 相关阅读:
    struct{} //长篇更新
    channel //长篇更新
    切片 //长篇更新
    引用
    核心:数据篇
    ARM指令解析
    arm寄存器解析
    Java-Selenium,获取下拉框中的每个选项的值,并随机选择某个选项
    log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
    eclipse安装springsource-tool-suite遇到的问题及解决方案
  • 原文地址:https://www.cnblogs.com/lufy/p/2532627.html
Copyright © 2020-2023  润新知