jQuery联动日历的实例解析

<p style="text-align: center">

一、要实现的功能

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

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

二、分析:

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

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

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

rush:js;"> //点击更新前一个月 $(".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(); })

以上就是本文的全部内容,希望对大家有所帮助,谢谢对编程之家的支持

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...