您的位置:首页 > 其它

随机改变背景颜色

2015-11-17 00:00 344 查看
摘要: 随机颜色

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>随按钮改变背景颜色</title>
<script language="javascript" type="text/javascript">

function changeBackground()
{
//获取到基本颜色
var color="#"+("00000"+(Math.floor(Math.random()*parseInt("ffffff",16))).toString(16)).substr(-6);
document.body.style.backgroundColor = color;//改变背景色
}
</script>
</head>

<body>
<p><input id="btn" type="button" value="随机改变背景颜色" onClick="changeBackground()"></p>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  随机颜色