js 点名

<!doctype html>
<html>

<head>

    <meta charset="utf-8">

    <title>点人名</title>

    <meta content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width" name="viewport"/>

    <meta content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)" name="viewport"/>
    
    <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
    

<style>
    h2{
        font-size: 5em;
        text-align: center;
        margin-top: 50px;
        height: 250px;
        width: 350px;
        margin: 50px auto;
        border: 1px solid #ccc;
        box-shadow: 0 0 5px #000;
        line-height: 250px;
    }
    .btn{
        text-align:center;
        
    }
    .btn input{
        padding:10px 20px;
        margin:10px 30px;
        color:#000;
    }
    .texrt{
        text-shadow: 1px 2px 4px red;
    }
</style>
</head>


<body>

    
    
    
    
    <h2 id="num">
        开始点人
    </h2>
    
    <div class="btn">
        <input type="button" value="开始" id="start"/>
        <input type="button" value="结束" id="stop"/>
    </div>
    
    
    
    
    
    
    <script>

        var arry = ['张武','赵欣','赵瑛','赵子怡','菲菲','雷囧','马季','小辣椒','龙卷风','名阿凡','秒速','艾莉婕','奥拉基'];
        var num = document.getElementById('num');
        var start = document.getElementById('start');
        var stop = document.getElementById('stop');
        var time = null;
        start.onclick=function(){
            num.className  = 'texrt';
            this.disabled=true; 
            time = setInterval(function(){
                    var n = Math.round(Math.random()*(arry.length-1));    //随机产生 0 - arry.length 之间的数字
                    num.innerHTML = arry[n];
                },50);
        };
        
        stop.onclick=function(){
            start.disabled=false; 
            clearInterval(time);
        };
        
    </script>
</body>
</html>

 

转载于:https://www.cnblogs.com/xinlinux/p/4312628.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值