自动点名器

1 篇文章 0 订阅

点名器,刚学习web,想写点东西就写个这个小玩意。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style>
            .box{width: 200px; height: 200px ;color: red; background-color: aqua; float: left;}
            .box2{width: 100px; height: 100px; background-color: red; }
            .btn{width: 40px; height: 30px; background-color: red; color:  azure; display: inline-block;
            position: relative; left: 60px; top: 160px;}

        </style>
    </head>
    <body>
        <div class="box" id="box">
            
        </div>
        <button class="btn" id="btn"></button>
        <script>
            var oBox = document.getElementById("box");
            var obtn = document.getElementById("btn");
            var time;//点名计时器
            var time1;//自动点击计时器
            var b=true;
            var a =["张三","李四","王五","马六","七八","九十","旺旺","小福贵"];//定义数组
            
           time1 = setInterval(function(){
               obtn.click();
           }, 3000)//自动点击器 每隔3秒点击一下!不想要删掉就行

           

            obtn.onclick =function(){
               
            if(b){
                b=false;
                time = setInterval(function(){
                    oBox.innerHTML =a[Math.floor(Math.random()*(a.length-1))] //定义的名字随机出现
                },20)
                
            }else{
                clearInterval(time);
                oBox.innerHTML =a[Math.floor(Math.random()*(a.length-1))] 
                b=true;
            }
        }//随机点名方法  /采取点击一下开始,再次点击结束,方便快捷
            
        </script>
    </body>
</html>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值