Blogger Information
Blog 10
fans 0
comment 0
visits 6391
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
点击随机产生背景色
俞斌的博客
Original
553 people have browsed it

实例

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>点击随机产生背景色</title>
	
</head>
<body>
	<button onclick="beijingColor()">随机产生背景色</button>
	
	<script type="text/javascript">
		function beijingColor()
		{
			var bg = document.getElementsByTagName("body")[0];
			var r = Math.round(Math.random() * 255);
			var g = Math.round(Math.random() * 255);
			var b = Math.round(Math.random() * 255);
			var co = "rgb(" + r + "," + g + "," + b  + ")";
			bg.style.background = co;
		}
	</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post