web前端第三次作业

一、使用js完成抽奖项目效果和内容自定义

代码如下:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>抽奖活动</title>
    <style>
       body {
            font-family: "黑体";
            text-align: center;
            margin-top: 180px;
        }
        button {
            padding: 10px 20px;
            font-size: 16px;
            margin: 10px;
            cursor: pointer;
            border: none;
            border-radius: 5px;
        }
        #start{
            background-color: palevioletred;
            color: white;
        }
        #end{
            background-color: deepskyblue;
            color: white;
        }
        #wp{
            font-family: "黑体";
            margin-top: 50px;
            font-size: 30px;     
        }
    </style>
</head>
<body>
    <h1>随机抽奖活动</h1>
    <button id="start">开始</button>
    <button id="end">结束</button>
    <div id="wp">中奖物品</div>
    <script>
        var ostart=document.getElementById('start');
		var oend=document.getElementById('end');
		var otxt=document.getElementById('wp');
        var timer;
			var m;
			var list=['平板','现金200元','pad','购物卡','手机','购物卡','音响','电动车','现金200元','谢谢','谢谢','谢谢','谢谢','谢谢','谢谢','谢谢']
			// 开始
			ostart.onclick=function(){
				timer=setInterval(function(){
					// 产生随机数
					m=parseInt(Math.random()*list.length);
					// 修改html
					otxt.innerHTML=list[m]
					// 修改图片 .setAttribute('src',list[m])
				},1000)
			}
			// 停止
			oend.onclick=function(){	
				clearInterval(timer);
				alert('恭喜抽中'+list[m]);
				list.splice(m,1,'谢谢');
			}
    </script>
</body>
</html>

效果如下:

二、每日一讲视频

每日一讲

相关推荐
开开心心就好5 小时前
批量提取PDF中的图片,直接导出原图
前端·javascript·支持向量机·智能手机·pdf·html·启发式算法
Setsuna_F_Seiei8 小时前
前端转型 Agent 开发 05 之 Agent Hooks 与 Checkpointer(让 Agent 从全自动转变人为可掌控)
前端·agent·ai编程
百万蹄蹄向前冲9 小时前
风扇转了一晚上MVP专家团翻车事故
前端·人工智能
默_笙10 小时前
🏛 给 AI 配一间办公室:Harness Engineering 六大模块与它的实现
前端·javascript
linux_cfan11 小时前
videojs v10 源代码系列解读:14 · 谓词守卫:在运行时安全地调用能力
前端·javascript·音视频
kyriewen11 小时前
我扒了 10,221 条 JD:腾讯技术岗 75% 在要 AI
前端·人工智能·ai编程
郑州光合科技余经理12 小时前
同城外卖小程序开发:下单成功后,后台导出能不能对上用户端状态
开发语言·前端·git·后端·uni-app·php·ai编程
IT_陈寒13 小时前
Vue的响应式让我熬到凌晨三点,原来漏了这个小细节
前端·人工智能·后端
Blanche150013 小时前
利用 RAG 为答疑机器人扩展知识范围
前端
天若有情67313 小时前
【纯前端小工具】公历生日转农历,批量查询每年农历生日对应的公历日期(GitHub Pages在线直接用)
前端·javascript·github pages·农历转换·lunisolar·网页小工具