java 日历签到功能_基于jquery实现日历签到功能_jquery - prev

.singer_r_img{display:block;width:114px;height:52px;line-height:45px;background:url(images/sing_week.gif) right 2px no-repeat;vertical-align:middle;*margin-bottom:-10px;text-decoration:none;}

.singer_r_img:hover{background-position:right -53px;text-decoration:none;}

.singer_r_img span{margin-left:14px;font-size:16px;font-family:'Hiragino Sans GB','Microsoft YaHei',sans-serif !important;font-weight:700;color:#165379;}

.singer_r_img.current{background:url(images/sing_sing.gif) no-repeat 0 2px;border:0;text-decoration:none;}

.sign table{border-collapse: collapse;border-spacing: 0;width:100%;}

.sign th,.sign td {width: 30px;height: 40px;text-align: center;line-height: 40px;border:1px solid #e3e3e3;}

.sign th {font-size: 16px;}

.sign td {color: #404040;vertical-align: middle;}

.sign .on {background-color:red;}

.calendar_month_next,.calendar_month_prev{width: 34px;height: 40px;cursor: pointer;background:url(images/sign_arrow.png) no-repeat;}

.calendar_month_next {float: right;background-position:-42px -6px;}

.calendar_month_span {display: inline;line-height: 40px;font-size: 16px;color: #656565;letter-spacing: 2px;font-weight: bold;}

.calendar_month_prev {float: left;background-position:-5px -6px;}

.sign_succ_calendar_title {text-align: center;width:398px;border-left:1px solid #e3e3e3;border-right:1px solid #e3e3e3;background:#fff;}

.sign_main {width: 400px;border-top:1px solid #e3e3e3;font-family: "Microsoft YaHei",SimHei;}

calendar.js

var calUtil = {

//当前日历显示的年份

showYear:2015,

//当前日历显示的月份

showMonth:1,

//当前日历显示的天数

showDays:1,

eventName:"load",

//初始化日历

init:function(signList){

calUtil.setMonthAndDay();

calUtil.draw(signList);

calUtil.bindEnvent();

},

draw:function(signList){

//绑定日历

var str = calUtil.drawCal(calUtil.showYear,calUtil.showMonth,signList);

$("#calendar").html(str);

//绑定日历表头

var calendarName=calUtil.showYear+"年"+calUtil.showMonth+"月";

$(".calendar_month_span").html(calendarName);

},

//绑定事件

bindEnvent:function(){

//绑定上个月事件

$(".calendar_month_prev").click(function(){

//ajax获取日历json数据

var signList=[{"signDay":"10"},{"signDay":"11"},{"signDay":"12"},{"signDay":"13"}];

calUtil.eventName="prev";

calUtil.init(signList);

});

//绑定下个月事件

$(".calendar_month_next").click(function(){

//ajax获取日历json数据

var signList=[{"signDay":"10"},{"signDay":"11"},{"signDay":"12"},{"signDay":"13"}];

calUtil.eventName="next";

calUtil.init(signList);

});

},

//获取当前选择的年月

setMonthAndDay:function(){

switch(calUtil.eventName)

{

case "load":

var current = new Date();

calUtil.showYear=current.getFullYear();

calUtil.showMonth=current.getMonth() + 1;

break;

case "prev":

var nowMonth=$(".calendar_month_span").html().split("年")[1].split("月")[0];

calUtil.showMonth=parseInt(nowMonth)-1;

if(calUtil.showMonth==0)

{

calUtil.showMonth=12;

calUtil.showYear-=1;

}

break;

case "next":

var nowMonth=$(".calendar_month_span").html().split("年")[1].split("月")[0];

calUtil.showMonth=parseInt(nowMonth)+1;

if(calUtil.showMonth==13)

{

calUtil.showMonth=1;

calUtil.showYear+=1;

}

break;

}

},

getDaysInmonth : function(iMonth, iYear){

var dPrevDate = new Date(iYear, iMonth, 0);

return dPrevDate.getDate();

},

bulidCal : function(iYear, iMonth) {

var aMonth = new Array();

aMonth[0] = new Array(7);

aMonth[1] = new Array(7);

aMonth[2] = new Array(7);

aMonth[3] = new Array(7);

aMonth[4] = new Array(7);

aMonth[5] = new Array(7);

aMonth[6] = new Array(7);

var dCalDate = new Date(iYear, iMonth - 1, 1);

var iDayOfFirst = dCalDate.getDay();

var iDaysInMonth = calUtil.getDaysInmonth(iMonth, iYear);

var iVarDate = 1;

var d, w;

aMonth[0][0] = "日";

aMonth[0][1] = "一";

aMonth[0][2] = "二";

aMonth[0][3] = "三";

aMonth[0][4] = "四";

aMonth[0][5] = "五";

aMonth[0][6] = "六";

for (d = iDayOfFirst; d < 7; d++) {

aMonth[1][d] = iVarDate;

iVarDate++;

}

for (w = 2; w < 7; w++) {

for (d = 0; d < 7; d++) {

if (iVarDate <= iDaysInMonth) {

aMonth[w][d] = iVarDate;

iVarDate++;

}

}

}

return aMonth;

},

ifHasSigned : function(signList,day){

var signed = false;

$.each(signList,function(index,item){

if(item.signDay == day) {

signed = true;

return false;

}

});

return signed ;

},

drawCal : function(iYear, iMonth ,signList) {

var myMonth = calUtil.bulidCal(iYear, iMonth);

var htmls = new Array();

htmls.push("

");

htmls.push("

");

htmls.push("

下月");

htmls.push("

上月");

htmls.push("

");

htmls.push("");

htmls.push("

");

htmls.push("");

htmls.push("

");

htmls.push("" + myMonth[0][0] + "");

htmls.push("" + myMonth[0][1] + "");

htmls.push("" + myMonth[0][2] + "");

htmls.push("" + myMonth[0][3] + "");

htmls.push("" + myMonth[0][4] + "");

htmls.push("" + myMonth[0][5] + "");

htmls.push("" + myMonth[0][6] + "");

htmls.push("");

var d, w;

for (w = 1; w < 7; w++) {

htmls.push("

");

for (d = 0; d < 7; d++) {

var ifHasSigned = calUtil.ifHasSigned(signList,myMonth[w][d]);

console.log(ifHasSigned);

if(ifHasSigned){

htmls.push("" + (!isNaN(myMonth[w][d]) ? myMonth[w][d] : " ") + "");

} else {

htmls.push("" + (!isNaN(myMonth[w][d]) ? myMonth[w][d] : " ") + "");

}

}

htmls.push("");

}

htmls.push("");

htmls.push("");

htmls.push("");

return htmls.join('');

}

};

希望本文所述对大家学习javascript程序设计有所帮助。

这篇文章主要介绍了jQuery中prev()方法用法,实例分析了prev()方法的功能、定义及取得匹配元素集合中每个元素紧邻的前一个同辈元素使用技巧,需要的朋友可以参考下本文实例讲述了jQuery中prev()方法用法。分享给大家供大家参...

...中计划功能的说明。其中大部分功能在Visual Studio “15” Preview 4中能运行。现在是最好的试用时期,请记录下你们的想法。

C#7.0语言增加了许多的新功能,促使专注于数据消费,简化代码和性能。

或许最大的特征是...

...nput name="name" />, ]

8、prev + next

匹配所有紧跟在 prev 之后的 next 元素

参数:prev 任何选择器;next 一个有效选择器并且紧接着第一个选择器

如:

匹配所有跟在lable后面

...中计划功能的说明。其中大部分功能在Visual Studio “15” Preview 4中能运行。现在是最好的试用时期,请记录下你们的想法。

C#7.0语言增加了许多的新功能,促使专注于数据消费,简化代码和性能。

或许最大的特征是...

prev() 定义和用法 prev() 函数把指向当前元素的指针移动到上一个元素的位置,并返回该元素值。 如果内部指针已经超过数组的第一个元素之前,函数返回 false。 语法 prev(array)参数 描述 array 必...

...e.LinkedListNode = function () { this.data = null;//数据域 this.prev = null;//前驱 this.next = null;//后驱 }; Dare.extend(Dare.LinkedListNode, Dare); Dare

prev() 函数被用来匹配元素集的前一个兄弟元素,仅仅只有前一个兄弟元素被选择,其子元素将被忽略。本文主要介绍了jQuery里prev()的简单操作代码,非常不错,具有参考借鉴价值,需要的朋友可以参考下,希望能帮助到大家。...

一 介绍prev + next选择器用于匹配所有紧接在prev元素后的next元素。其中,prev和next是两个相同级别的元素。prev + next选择器的使用方法如下: $("prev + next");prev是指任何有效...

...erator. */

/* list节点*/

typedef struct listNode {

struct listNode *prev; // 前向指针

struct listNode *next; // 后向指针

void *val

正如标题所言其所用为匹配 prev 元素之后的所有 siblings 元素,下面为大家分享个示例,不了解的朋友可以学习下1、prev ~ siblings:匹配 prev 元素之后的所有 siblings 元素 2、(1)prev:任何有效选择器 (2)siblings:...

POWERED BY ©点凡CMS-PHP技术站 ALL RIGHTS RESERVED  本网站部分内容来源于互联网,如有侵犯版权请来信告知,我们将立即处理(363623854#qq.com)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值