js题目3

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .whole{
      width: 500px;
      height: 500px;
      margin: 0 auto;
    }
    .reveal{
      background-color: aliceblue;
      text-align: center;
    }
    .control{
      display: flex;
      justify-content: center;
      background-color: antiquewhite;
    }
    .first,.third{
      opacity: 0.7;
    }
  </style>
</head>
<body>
  <div class="whole">
    <div class="reveal">
      <div class="first">20250101李锐</div>
      <div class="second">20250102王宇</div>
      <div class="third">202501023张萌</div>
    </div>
    <div class="control">
      <div class="start">
        <button>开始</button>
      </div>
      <div class="end">
        <button>结束</button>
      </div>
    </div>
  </div>
  <script>
    const data=['20250101李锐','20250102王宇','202501023张萌','20250104刘阳','20250105程佳','20250106杨宁','20250107赵辉','20250108黄兴',
    '20250109周瑶','20250110吴俊','20250111徐辉','20250112孙涛','20250113胡玲','20250114朱杰','20250115高城','20250116林锐','20250117郭宇',
    '20250118马军','20250119马俊','20250120罗婷','20250121梁峰','20250122宋佳','20250123郑阳','20250124谢晖','20250125韩雪','20250126唐睿',
    '20250127冯玉','20250128宇浩','20250129东瑞','20250130萧玉','20250131程琳','20250132王宇','20250133曹杰','20250134邓瑶','20250135徐畅',
    '20250136博宇','20250137沈瑞','20250138曾辉','20250139鹏泰','20250140吕佳','20250141苏瑶','20250142卢阳','20250143蒋军','20250144蔡慧',
    '20250145嘉城','20250146丁宁','20250147魏峰','20250148薛宇','20250149叶萌','20250150闫旭']
    let time=0
    const first=document.querySelector('.first')
    const second=document.querySelector('.second')
    const third=document.querySelector('.third')
    const start=document.querySelector('.start')
    start.addEventListener('click',function(){
      time=setInterval(function(){
        const random=parseInt(Math.random() * data.length)
        first.innerHTML=data[random-1]
        second.innerHTML=data[random]
        third.innerHTML=data[random+1]
      },35)
    })
    const end=document.querySelector('.end')
    end.addEventListener('click',function(){
      clearInterval(time)
    })
  </script>
</body>
</html>

屏幕录制 2025-01-24 140810

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值