这是一个本来为我们语文老师写的代码,为什么不用别的语言写呢?因为我们学校的电脑质量太好了(恼
<html>
<head>
<meta charset="utf-8">
<title>随机学号生成器</title>
</head>
<body>
<script>
var stu=[0,301,302,303,304,305,306,307,308,309,310,311,312,313,
331,332,333,334,336,337,338,339,340,341,342,344,346,347,348];
var x=1,y=28;
var guy=(Math.round(Math.random()*(y-x)+x));
document.write(stu[guy]);
document.write("<br/>");
document.write("<br/>");
document.write("<br/>");
document.write("<br/>");
document.write("<br/>");
document.write("<br/>");
document.write("<br/>");
document.write("This project is made by STT.");
document.write("<br/>");
document.write("全员二十八分之一模式");
</script>
</body>
</html>
怎么用呢很简单,给你们一个模板
<html>
<head>
<meta charset="utf-8">
<title>随机数生成器</title>
</head>
<body>
<script>
var x=1,y=100;//你抽取数字的范围,包括x和y,你只能变动这两个值
var num=(Math.round(Math.random()*(y-x)+x));
document.write(num);
document.write("<br/>");
document.write("<br/>");
document.write("<br/>");
document.write("This project is made by STT.");
</script>
</body>
</html>
在你电脑上新建一个文本文档,把代码复制进去,然后关掉,把后缀.txt改成.html
然后就点击就可以在你的浏览器上打开了,当你刷新(按f5)的时候,数字将会随机出现一个
更多推荐
js代码:随机数生成器(简单版)
发布评论