码迷,mamicode.com
首页 > 其他好文 > 详细

随机点名程序与万年历

时间:2017-09-27 10:00:41      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:utf-8   oct   rip   div   type   second   int   time   meta   

 随机点名程序

document.write(Math.random());
 var stu = ["张三", "王五", "张二", "张一", "石大", "郭三", "冯二", "平五"];
 var ran = Math.random();
 var ran = ran * stu.length;
 var ran = Math.floor(ran);
 document.write(stu[ran]);

万年历

<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <title></title>
</head>
<body>
   <div id="a"></div>
</body>
</html>
<script>
 function jgxs(){
   var time = new Date();
   var year = time.getFullYear();
   var month = time.getMonth()+1;
   var day = time.getDate();
   var hour = time.getHours();
   var min = time.getMinutes();
   var sec = time.getSeconds();
   var time2 = year+"年"+month+"月"+day+"日"+"&nbsp;"+hour+":"+min+":"+sec;
   document.getElementById("a").innerHTML=time2;  
 }
 window.setInterval("jgxs()",500) 
</script>

随机点名程序与万年历

标签:utf-8   oct   rip   div   type   second   int   time   meta   

原文地址:http://www.cnblogs.com/cmzhphp2017/p/7599804.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!