4月27 笔记(补充)

笔记

点击查看代码
</details><!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<style type="text/css">
			*{margin: 0; padding: 0;}
			#top{
				height: 400px;
				line-height: 400px;
				text-align: center;
			}
			#top button{
				width: 100px;
				height: 50px;
			}
			.red{
				background-color: red;
			}
			.blue{
				background-color: blue;
			}
		</style>
	<body>
		<div id="top" class="red">
			<button onclick="changeColor()">改变背景颜色</button>
		</div>
	</body>
	<script type="text/javascript">
		function changeColor(){
			if(document.getElementById("top").className=="blue") {
				document.getElementById("top").className="red"
			} else{
				document.getElementById("top").className="blue"
			}
		}
	</script>
</html>

posted @ 2026-07-08 20:23  lvxuel  阅读(8)  评论(0)    收藏  举报