js实现简易的抽奖系统 您所在的位置:网站首页 点击抽奖按钮图片 js实现简易的抽奖系统

js实现简易的抽奖系统

2024-06-18 17:57| 来源: 网络整理| 查看: 265

实现效果如下: 实现效果 效果说明: 1、共有90个号码,在点击开始抽奖后,产生随机号码; 2、点击停止后,显示最后一次产生的随机号码,作为幸运号码; 3、在点击三次抽奖后,按钮内容显示为:次数已经用完,再点击时失效; 4、效果图中号码为使用js生成的。 由于涉及的代码量不多,故全部在index.html中,具体代码如下: index.html

抽奖系统的实现 * { padding: 0; margin: 0; } li { list-style: none; } #box { position: relative; margin: 50px auto; width: 600px; height: 540px; border: 1px solid #f46e00; } #show { float: left; width: 600px; height: 460px; background: #cccccc; } #start { float: left; width: 100px; height: 40px; color: #ededed; user-select: none; line-height: 40px; text-align: center; margin-left: 250px; margin-top: 20px; } .start { background: #8a6de9; } .list { float: left; width: 60px; height: 51px; font-size: 24px; border-radius: 60px; line-height: 50px; background: #8a6de9; text-align: center; color: #e8e8e8; } .stop { background: #888888; } .select { color: #8a6de9; background: #e8e8e8; } .lucky { display: none; position: absolute; left: 0; top: 0; width: 600px; height: 460px; line-height: 460px; text-align: center; font-size: 56px; color: #0f0; background: rgba(0, 0, 0, .7); }

开始抽奖

let show = document.getElementById('show'); let start = document.getElementById('start'); let lists = document.getElementsByClassName('list'); let lucky = document.getElementsByClassName('lucky')[0]; let src = ''; let num = 0; let clickNum = 0; let interval = 0; for (let i = 1; i


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有