简单的实现一下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Remove Color</title>
<style>
.box {
width: 100px;
height: 100px;
border: 2px black solid;
padding: 10px;
margin: 10px;
}
#green {
background-color: green;
}
#red {
background-color: red;
}
</style>
<script>
function removeColor() {
document.getElementById("green").style.backgroundColor = "white";
document.getElementById("red").style.backgroundColor = "white";
}
</script>
</head>
<body>
<p id="green" class="box">绿盒子</p>
<p id="red" class="box">红盒子</p>
<button type="button" onclick="removeColor()">清除颜色</button>
</body>
</html>