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

时间:2014-02-18 23:12:26   收藏:0   阅读:470

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

原文:http://www.cnblogs.com/lowbrid/p/3554283.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!