JavaScrip通過按鈕更換背景顏色

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

效果
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章