<!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>
效果