您的位置:首页 > 其它

点击按钮实现内容颜色的改变

2014-02-18 14:56 525 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" >
function changeColor(){
var red=Math.ceil(Math.random()*255);
var green=Math.ceil(Math.random()*255);
var blue=Math.ceil(Math.random()*255);
var color="#"+red.toString(16)+green.toString(16)+blue.toString(16);
document.getElementById("content").style.color=color;
document.getElementById("content").style.fontWeight="bold";
}
</script>
</head>
<body>
<p id="content">我要变换颜色!</p>
<input type="button" value="变换颜色" onclick="changeColor()"/>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: