这些是我在网上看到的很简单的例子但是里面都是经验 就是作者写的时候大小写没有分给我带来了排错学习的机会一定要记得 js对大小写的严谨,还有就是解决问题的思路,先解决问题然后在优化,在优化,在优化.
此时想起了上大学利用 VB 写的一个用时间加密的小程序,用它得了95分顺利通过考试哈哈….高兴的是别人写了N行别的程序而我写了不到30行.
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
| var str = "今天是星期" + "日一二三四五六".charAt(new Date().getDay());
var a = new Array("日", "一", "二", "三", "四", "五", "六"); var week = new Date().getDay(); alert(week); var str = "今天是星期"+ a[week]; alert(str);
var str = ""; var week = new Date().getDay(); if (week == 0) { str = "今天是星期日"; } else if (week == 1) { str = "今天是星期一"; } else if (week == 2) { str = "今天是星期二"; } else if (week == 3) { str = "今天是星期三"; } else if (week == 4) { str = "今天是星期四"; } else if (week == 5) { str = "今天是星期五"; } else if (week == 6) { str = "今天是星期六"; }
var str1 = "今天是星期"; var week = new Date().getDay(); switch (week) { case 0 : str1 += "日"; break; case 1 : str1 += "一"; break; case 2 : str1 += "二"; break; case 3 : str1 += "三"; break; case 4 : str1 += "四"; break; case 5 : str1 += "五"; break; case 6 : str1 += "六"; break; } alert(str); alert(str1);
|