HTML组件之:编写日历(1),HTML组件之:编写日历(1)
【 tulaoshi.com - Html 】
===编写日历一===getDays()函数接收哪月值和哪年值,并且建立一个有12个元素的数组,用来存放每月的天数,哪一年用来决定是不是闰年,在闰年中二月是29天,而不是闰年是28天。该函数返回指定月份的天数。
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/html/)以下是getDays():
function getDays(month, year) {
// create array to hold number of days in each month
var ar = new Array(12);
ar[0] = 31; // January
ar = (leapYear(year)) ? 29 : 28; // February
ar = 31; // March
ar = 30; // April
ar = 31; // May
ar = 30; // June
ar = 31; // July
ar = 31; // August
ar = 30; // September
ar = 31; // October
ar = 30; // November
ar = 31; // December
// return number of days in the specified month (parameter)
return ar[month];
}
来源:http://www.tulaoshi.com/n/20160129/1484776.html
看过《HTML组件之:编写日历(1)》的人还看了以下文章 更多>>