js 随机产生一注 三注 五注 双色球

<!DOCTYPE html>

<html>


<head>

<meta charset="UTF-8">

<title>双色球</title>

<style type="text/css">

#wrap {

width: 800px;

padding: 50px;

margin: 20px auto;

background: darkslategray;

text-align: center;

}

button {

width: 200px;

height: 50px;

outline: none;

font-size: 2rem;

border-radius: 20px;

margin: 50px 5px;

}

.numbox {

width: 700px;

/*height: 500px;*/

background: white;

margin: auto;

}

</style>

</head>


<body>

<div id="wrap">

<button>随机一注</button>

<button>随机三注</button>

<button>随机五注</button>

<div id="numbox"></div>

</div>

<script type="text/javascript">

var btn = document.getElementsByTagName('button');

btn[0].onclick = oneRandom;

btn[1].onclick = twoRandom;

btn[2].onclick = fiveRandom;


var numbox = document.getElementById('numbox');

// numbox.style.background = 'white';

numbox.className = 'numbox';


function fiveRandom() {

var tim = setInterval(function() {

numbox.innerHTML = '';

for(j = 0; j < 5; j++) {

one();

}

}, 10);


setTimeout(function() {

clearInterval(tim);

}, 800);

}


function twoRandom() {

var tim = setInterval(function() {

numbox.innerHTML = '';

for(j = 0; j < 3; j++) {

one()

}

}, 10);

setTimeout(function() {

clearInterval(tim);

}, 800);


}


function oneRandom() {

var tim = setInterval(function() {

numbox.innerHTML = '';

one();

}, 10);

setTimeout(function() {

clearInterval(tim);

}, 800);


}


function one() {

var arr1 = [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];

var arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];

var arr = [];

for(i = 0; i < 6; i++) {

var box = document.createElement('div');

box.style.width = '80px';

box.style.height = '80px';

box.style.display = 'inline-block';

box.style.border = '1px solid red';

box.style.boxShadow = '5px 5px 10px gray';

box.style.borderRadius = '50%';

box.style.background = 'red';

box.style.fontSize = '2rem';

box.style.color = 'white';

box.style.textAlign = 'center';

box.style.lineHeight = '80px';

box.style.margin = '20px 5px';

numbox.appendChild(box);


var num = Math.floor(Math.random() * arr1.length);

arr.push(arr1[num]);

box.innerText = arr1[num];

arr1[num] = arr1[arr1.length - 1];

arr1.pop();

}

var box1 = document.createElement('div');

box1.style.width = '80px';

box1.style.height = '80px';

box1.style.display = 'inline-block';

box1.style.border = '1px solid blue';

box1.style.boxShadow = '5px 5px 10px gray';

box1.style.borderRadius = '50%';

box1.style.background = 'blue';

box1.style.fontSize = '2rem';

box1.style.color = 'white';

box1.style.textAlign = 'center';

box1.style.lineHeight = '80px';

box1.style.margin = '20px 5px';

numbox.appendChild(box1);


var num2 = Math.floor(Math.random() * 16);

box1.innerText = arr2[num2];

var br_ = document.createElement('br');

numbox.appendChild(br_);


}

</script>

</body>


</html>

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值