首页 > 站长学院 > HTML&CSS > HTML组件之:编写日历(2)
 

HTML组件之:编写日历(2)

日期:2005-05-20 00:00:00  来源:中国站长学院
请您记住思索网的网址: http://www.4so.net  [加入收藏夹]

    ===编写日历一===

如果指定的年数可以被4整除,那么leapYear()函数将返回“true”,否则返回”false“:

function leapYear(year) {
if (year % 4 == 0) // basic rule
return true; // is leap year
/* else */ // else not needed when statement is "return"
return false; // is not leap year
}
getMonthName()函数返回指定月份的名字:
function getMonthName(month) {
// create array to hold name of each month
var ar = new Array(12);
ar[0] = "January";
ar[1] = "February";
ar[2] = "March";
ar[3] = "April";
ar[4] = "May";
ar[5] = "June";
ar[6] = "July";
ar[7] = "August";
ar[8] = "September";
ar[9] = "October";
ar[10] = "November";
ar[11] = "December";

// return name of specified month (parameter)
return ar[month];
}


 
 
热门信息
 
相关文章