<!DOCTYPE html>
<html>
<head>
<title>练习1</title>
<meta charset="UTF-8"/>
</head>
<h2>点击不同按钮设置不同颜色</h2>
<button onclick="body.style.backgroundColor='green';">绿色</button>
<button onclick="body.style.backgroundColor='Blue';">蓝色</button>
<button onclick="body.style.backgroundColor='pink';">粉色</button>
<button onclick="body.style.backgroundColor='yellow';">黄色</button>
</body>
</html>
效果