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>

浙公网安备 33010602011771号