国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

node.js|vue.js|jquery|angularjs|React|json|js教程|

服務(wù)器之家 - 編程語(yǔ)言 - JavaScript - jquery - 基于jquery實(shí)現(xiàn)日歷效果

基于jquery實(shí)現(xiàn)日歷效果

2022-02-17 19:28清靜清源 jquery

這篇文章主要為大家詳細(xì)介紹了基于jquery實(shí)現(xiàn)日歷效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了jquery實(shí)現(xiàn)日歷效果的具體代碼,供大家參考,具體內(nèi)容如下

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/**
 * 2021/3/6
 * Calendar
 */
 
/* get y Year m Month before days
 */
function getBDays( y, m ) {
 return (new Date(y, m, 1).getDay());
}
 
/* get y Year m Month total days
 */
function getTDays( y, m ) {
 return (new Date(y, m + 1, -1).getDate() + 1);
}
 
/* get y Year m Month last days
 */
function getBMDays( y, m ) {
 return (new Date(y, m, -1).getDate() + 1);
}
 
function Calendar( nowDate ) {
 // year, month, day
 this.year = nowDate.getFullYear();
 this.month = nowDate.getMonth();
 this.day = nowDate.getDate();
 
 // before days
 this.beforeDays = getBDays(this.year, this.month);
 // current month days
 this.totalDays = getTDays(this.year, this.month);
 // last month days
 this.lastDays = getBMDays(this.year, this.month);
 
 // save now date
 this.nowY = nowDate.getFullYear();
 this.nowM = nowDate.getMonth();
}
 
Calendar.prototype.initCalendar = function() {
 // get calendar id
 let calDiv = $("#Calendar").append("<table></table>");
 
 // get calendar table
 let calTable = $("#Calendar > table");
 
 // add calendar table tr
 for ( let n = 0; n < 8; n++ ) {
 calTable.append('<tr></tr>');
 }
 
 // get calendar table tr : header
 let calHeadTr = $("#Calendar > table > tr:first");
 
 // add calendar table tr th
 for ( let n = 0; n < 3; n++ ) {
 calHeadTr.append('<th></th>');
 }
 
 // select index > 0 tr
 let calBodyTr = $("#Calendar > table > tr:gt(0)");
 
 // add calendar table tr td
 for ( let n = 0; n < 7; n++ ) {
 calBodyTr.append('<td></td>');
 }
}
 
Calendar.prototype.insertDate = function( calName ) {
 // get calendar table tr td : header
 let calHeadTh = $("#Calendar > table > tr:first > th");
 
 // modify header content
 $(calHeadTh[0]).html("<a><</a>");
 $(calHeadTh[1]).html(`<a>${this.year} 年 ${this.month + 1} 月</a>`);
 $(calHeadTh[2]).html("<a>></a>");
 
 // add style to header
 $(calHeadTh[1]).attr({
 "colspan" : 5,
 "title" : calName
 });
 
 // weekday arrays
 const calWeekArr = ['日', '一', '二', '三', '四', '五', '六'];
 
 // get calendar table tr td : weekdays
 let calWeekTd = $("#Calendar > table > tr:eq(1) > td");
 for ( let n = 0; n < 7; n++ ) {
 $(calWeekTd[n]).html(`<a>${calWeekArr[n]}</a>`);
 }
 
 // get calendar table tr td : body
 let calBodyTd = $("#Calendar > table > tr:gt(1) > td");
 
 // insert before days
 for (let n = this.beforeDays - 1, lastDays = this.lastDays;
 n >= 0;
 n--, lastDays--) {
 $(calBodyTd[n]).html(`<a>${lastDays}</a>`);
 $(calBodyTd[n]).attr("class", "other-day");
 }
 // insert current days
 for (let n = this.beforeDays, i = 1;
  i <= this.totalDays;
  i++, n++) {
 $(calBodyTd[n]).html(`<a>${i}</a>`);
 
 if (i == this.day &&
  (new Date(this.year, this.month, 1).getMonth() == this.nowM) &&
  (new Date(this.year, this.month, 1).getFullYear() == this.nowY)) {
 $(calBodyTd[n]).attr("class", "now-day");
 }
 else {
 $(calBodyTd[n]).removeAttr("class", "now-day");
 }
 }
 
 // insert after days
 for (let n = this.beforeDays + this.totalDays, i = 1;
 n < calBodyTd.length;
 n++, i++) {
 $(calBodyTd[n]).html(`<a>${i}</a>`);
 $(calBodyTd[n]).attr("class", "other-day");
 }
}
 
Calendar.prototype.update = function( newDate ) {
 // year, month, day
 this.year = newDate.getFullYear();
 this.month = newDate.getMonth();
 this.day = newDate.getDate();
 
 // before days
 this.beforeDays = getBDays(this.year, this.month);
 // current month days
 this.totalDays = getTDays(this.year, this.month);
 // last month days
 this.lastDays = getBMDays(this.year, this.month);
}
 
function initDate() {
 // create Date object
 let now = new Date();
 let cal = new Calendar( now );
 
 // init and insert
 cal.initCalendar();
 cal.insertDate( 'MyDate' );
 
 // add click event to th:first
 $("#Calendar > table > tr:first > th:first").click(function(){
 now.setMonth( now.getMonth() - 1 );
 cal.update( now );
 cal.insertDate( 'MyDate' );
 });                        
 
 // add click event to th:last
 $("#Calendar > table > tr:first > th:last").click(function(){
 now.setMonth( now.getMonth() + 1 );
 cal.update( now );
 cal.insertDate( 'MyDate' );
 });
}
 
initDate();

html

?
1
2
3
4
5
6
7
8
9
10
11
12
13
<!DOCTYPE html>
<html>
 <head>
 <meta charset="utf-8" />
 <title>Document</title>
 <link href="css/dateCal.css" rel="stylesheet" media="screen">
 </head>
 <body>
 <div id="Calendar"></div>
 <script src="js/jquery.js"></script>
 <script src="js/dateCal.js"></script>
 </body>
</html>

CSS:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#Calendar {
 width: 200px;
 padding-bottom: 5px;
 box-shadow: 0 1px 3px #ccc;
 border: 1px solid #EDEDED;
}
 
#Calendar table {
 width: inherit;
 text-align: center;
 user-select: none;
 font-family: "Comic Sans MS";
 border-collapse: collapse;
 border-spacing: 0px;
}
 
#Calendar table tr th {
 background: #f8f8f8;
 font-size: 12px;
}
 
#Calendar table tr:nth-child(2) {
 background: #f8f8f8;
}
 
#Calendar table tr td {
 font-size: 10px;
}
 
#Calendar table tr td.now-day {
 color: red;
}
 
#Calendar table tr td.other-day {
 color: lightgray;
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:https://blog.csdn.net/qq_35068659/article/details/114459393

延伸 · 閱讀

精彩推薦
  • jqueryjQuery是用來(lái)干什么的 jquery其實(shí)就是一個(gè)js框架

    jQuery是用來(lái)干什么的 jquery其實(shí)就是一個(gè)js框架

    jQuery是一bai個(gè)簡(jiǎn)潔而快速的JavaScript庫(kù),可用于du簡(jiǎn)化zhi事件處理,HTML文檔遍歷,Ajax交互和dao動(dòng)畫,以更快速開發(fā)網(wǎng)站...

    jQuery教程網(wǎng)8842022-01-17
  • jqueryjQuery使用hide()、toggle()函數(shù)實(shí)現(xiàn)相機(jī)品牌展示隱藏功能

    jQuery使用hide()、toggle()函數(shù)實(shí)現(xiàn)相機(jī)品牌展示隱藏功能

    這篇文章主要介紹了jQuery使用hide()、toggle()函數(shù)實(shí)現(xiàn)相機(jī)品牌展示隱藏功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考...

    Schieber11822022-01-11
  • jqueryjquery插件實(shí)現(xiàn)搜索歷史

    jquery插件實(shí)現(xiàn)搜索歷史

    這篇文章主要為大家詳細(xì)介紹了jquery插件實(shí)現(xiàn)搜索歷史,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下...

    阿飛超努力8462022-03-09
  • jqueryjQuery實(shí)現(xiàn)本地存儲(chǔ)

    jQuery實(shí)現(xiàn)本地存儲(chǔ)

    這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)本地存儲(chǔ),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下...

    李大璟10682021-12-16
  • jqueryjquery實(shí)現(xiàn)穿梭框功能

    jquery實(shí)現(xiàn)穿梭框功能

    這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)穿梭框功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下...

    陳濤輝8412022-01-04
  • jqueryjquery插件實(shí)現(xiàn)圖片懸浮

    jquery插件實(shí)現(xiàn)圖片懸浮

    這篇文章主要為大家詳細(xì)介紹了jquery插件實(shí)現(xiàn)圖片懸浮,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下...

    阿飛超努力5802022-03-03
  • jqueryjQuery實(shí)現(xiàn)鼠標(biāo)拖動(dòng)圖片功能

    jQuery實(shí)現(xiàn)鼠標(biāo)拖動(dòng)圖片功能

    這篇文章主要介紹了jQuery實(shí)現(xiàn)鼠標(biāo)拖動(dòng)圖片功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以...

    lucascube5812022-02-10
  • jqueryjQuery treeview樹形結(jié)構(gòu)應(yīng)用

    jQuery treeview樹形結(jié)構(gòu)應(yīng)用

    這篇文章主要為大家詳細(xì)介紹了jQuery treeview樹形結(jié)構(gòu)應(yīng)用,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下...

    Lqq77s9342022-02-20
主站蜘蛛池模板: 国产激情在线观看 | 久久久久综合视频 | 国产视频二区 | 日韩在线精品 | 国产高清亚洲 | 久久国产欧美日韩精品 | 成年人视频免费在线看 | 日韩a∨精品日韩在线观看 国产高清视频在线观看 | 国产精品福利在线 | 欧美成人久久 | 国产精品精品 | 久久一区视频 | 精品一区二区在线观看 | 国产99久久| 免费视频国产 | 日韩精品一区二区三区在线观看 | 可以免费看黄色的网站 | 久久久精 | 久久久免费视频观看 | 在线免费观看av的网站 | 欧美日在线 | 久久中文字幕一区二区 | 欧美一区二区在线播放 | 九九热在线免费视频 | 久久mm | 久久久久久久久久久久免费 | 免费裸体无遮挡黄网站免费看 | 亚洲精品com | 天天色av | 成人午夜毛片 | 中文字幕第二页 | 午夜精品久久久久久久久久久久 | 成人h在线| 99精品国产一区二区三区 | 三级成人在线 | 成人福利视频 | 日本手机在线视频 | 在线永久免费观看日韩a | 成人激情视频免费在线观看 | 亚洲激情在线 | 精品久久97 |