码迷,mamicode.com
首页 > Web开发 > 详细

php课程---随机数

时间:2016-02-21 21:22:03      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<div id="sj"></div>
<input type="button" value="开始" onclick="ShowNumber()" />
</body>

<script type="text/javascript">
var arr = new Array(
        "0","1","2","3","4","5","6","7","8","9"
    );
var bs = 0;
function ShowNumber()
{
    var bian = Math.floor( Math.random()*10);
    
    var s = document.getElementById("sj");
    
    s.innerText = arr[bian];
    
    bs = bs+1;
    
    //s.innerText = bs;
    
    if(bs==5)
    {
        window.clearTimeout(jian);
    }
    else
    {
        var jian = window.setTimeout("ShowNumber()",30);
    }
    
    
    
}
</script>
</html>

点击开始按钮后,会得到一个随机数,刷新之后还可以得到另一个

php课程---随机数

标签:

原文地址:http://www.cnblogs.com/0927wyj/p/5205525.html

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