还在为今天吃点啥感到纠结么?

<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>随机点餐器</title>
		<style>
			* {
				margin: 0px;
				padding: 0px;
			}
			
			#main {
				margin: 100px;
				background: #ff6600;
				width: 520px;
				padding: 50px;
				border-radius: 20px 20px 20px 20px;
				box-shadow: 0 2px 12px #666666;
			}
			
			#box {
				background: #cccccc;
				margin: 50px;
				padding: 20px;
				font-size: 55px;
				font-weight: bold;
				border-radius: 15px 15px 15px 15px;
				box-shadow: 0 2px 12px #666666;
			}
			
			#bt {
				width: 100px;
				font-size: 20px;
				font-weight: bold;
				background-color: green;
				border-radius: 8px 8px 8px 8px;
				box-shadow: 0 2px 12px #666666;
				cursor: pointer;
				padding: 5px;
			}
		</style>
		<script>
			var namelist = [
				"辣子鸡", "水饺", "麻辣烫", "火锅",
				"米线", "烤肉", "日本料理",
				"麻辣香锅", "烤鱼", "烤串", "螺蛳粉",
			];

			var mytime = null;

			function doit() {
				var bt = document.getElementById("bt");
				if(mytime == null) {
					bt.innerHTML = "停 止";
					bt.style.backgroundColor = "red";
					show();
				} else {
					bt.innerHTML = "开 始";
					bt.style.backgroundColor = "green";
					clearTimeout(mytime);
					mytime = null;
				}
			}

			function show() {
				var box = window.document.getElementById("box");
				var num = Math.floor((Math.random() * 100000)) % namelist.length;
				box.innerHTML = namelist[num];
				mytime = setTimeout("show()", 50);
			}
		</script>
	</head>

	<body>
		<center>
			<div id="main">
				<div id="box">随机点餐器</div>
				<button id="bt" onclick="doit()">开 始</button>
			</div>
		</center>
	</body>

</html>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值