js制作随机抽奖,(指定数字范围内随机出现一个数字)转载请注明出处

转载请注明出处,原文链接https://blog.csdn.net/qq_45549336/article/details/115255581?spm=1001.2014.3001.5501在这里插入图片描述
在这里插入图片描述

<html>

<head>
        
    <meta charset="UTF-8">
        <title>抽奖</title>
        <style type="text/css">
        body {
    
    
            background-color:#130f40;
            font-size: 70px;
            text-align: center;
            margin: 0;
            padding: 0;
        }

        .start-button {
    
    
            width: 270px;
            height: 40px;
            border-width: 0px;
            border-radius: 3px;
            background: #1E90FF;
            cursor: pointer;
            outline: none;
            font-family: Microsoft YaHei;
            color: white;
            font-size: 17px;
           
        }

        .start-button:hover {
    
    
            /* 鼠标移入按钮范围时改变颜色 */
            background: #5599FF;
        }
    </style>
     
    <script type="text/javascript">
        var run = false;
        function count() {
    
    
            num.innerHTML = parseInt(Math.random() * 100);
        }
        function a() {
    
    
            if (true == run) {
    
    
                clearInterval(timerID);
                start.value = "开始";
                run = false;
            } else if (false == run) {
    
    
                timerID = setInterval("count()", 10);
                start.value = "暂停";
                run = true;
            }
        }
    </script>
</head>

<body>
    <div style="font-size: 250px;">
        <font id="num" face="impact" color="#eb4d4b">100</font>
        <div></div>
        <input class="start-button" type="button" id="start" value="开始抽奖" onclick="a()" />
    </div>

</body>

</html>

 

转载请注明出处,原文链接https://blog.csdn.net/qq_45549336/article/details/115255581?spm=1001.2014.3001.5501

猜你喜欢

转载自blog.csdn.net/qq_45549336/article/details/115255581