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>

效果
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/The_Handsome_Sir/article/details/106503610
今日推荐