HTML下的点名

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title></title>

<style>

*{

margin-left: 0px;

margin-top: 0px;

}

.container{

background-image: url(https://img.zcool.cn/community/01deac5b71220fa801206a3594899b.jpg@1280w_1l_2o_100sh.jpg);

background-color: aqua;

width: 1000px;

height: 480px;

border: 1px solid rgb(0, 255, 157);

position:absolute;

left: 50%;

margin-left: -500px;

text-align: center;

line-height: 100px;

margin-top: 150px;

}

.box,.box2{

width: 300px;

height: 300px;

background-image: url(https://img.chuapp.com/wp-content/uploads/2016/08/201608231471931218.gif?imageView2/2/w/700);

border-radius: 50%;

/* 水平位置居中 */

margin: auto;

margin-top: 50px;

text-align: center;

line-height: 300px

}

.box2{

background-color: blue;

}

#show{

font-size: 30px;

color: rgb(12, 14, 1);

font-weight: bolder;

}

#start{

width: 300px;

height: 50px;

background-color: rgb(0, 255, 170);

}

</style>

</head>

<body>

<div class="container">

<div class="box" id="box">

<span id="show">就决定是你了</span>

</div>

<button id="start" οnclick="change()">点名</button>

</div>

</body>

</html>

<script>

var flag = false

var awards = ["张三","李四","王二狗","小黄毛","绿茶","细狗","周扒皮","狗剩"]

var box = document.getElementById("box")

var show = document.getElementById("show")

var start = document.getElementById("start")

var timer

function change(){

if(!flag) {

flag = true

start.innerHTML="停止"

timer = setInterval(function(){

let index = Math.floor(Math.random()*awards.length)

show.innerHTML = awards[index]

box.setAttribute("class","box")

},10)

}else{

flag = false

start.innerHTML= "点名"

clearInterval(timer)

box.setAttribute("class","box")

}

}

</script>

相关推荐
玩电脑的辣条哥2 小时前
Python如何播放本地音乐并在web页面播放
开发语言·前端·python
ew452182 小时前
ElementUI表格表头自定义添加checkbox,点击选中样式不生效
前端·javascript·elementui
suibian52352 小时前
AI时代:前端开发的职业发展路径拓宽
前端·人工智能
Moon.92 小时前
el-table的hasChildren不生效?子级没数据还显示箭头号?树形数据无法展开和收缩
前端·vue.js·html
垚垚 Securify 前沿站2 小时前
深入了解 AppScan 工具的使用:筑牢 Web 应用安全防线
运维·前端·网络·安全·web安全·系统安全
工业甲酰苯胺5 小时前
Vue3 基础概念与环境搭建
前端·javascript·vue.js
mosquito_lover16 小时前
怎么把pyqt界面做的像web一样漂亮
前端·python·pyqt
柴柴的小记9 小时前
前端vue引入特殊字体不生效
前端·javascript·vue.js
柠檬豆腐脑9 小时前
从前端到全栈:新闻管理系统及多个应用端展示
前端·全栈
bin91539 小时前
DeepSeek 助力 Vue 开发:打造丝滑的颜色选择器(Color Picker)
前端·javascript·vue.js·ecmascript·deepseek