打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
V2.8数学对象--颜色变化.htm

<!Doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>数学对象</title>
     <style type="text/css">
      #show{
            width:200px;
            height:200px;
            margin:0 auto;
            color:white;
            background:#2c2c2c;
            text-align:center
           }

      </style>

 

   <script type="text/javascript">
 //PI
// E
//SQRT2
//Abs   绝对值
//Ceil  2.1 向上取  3
//Floor 2.6 向下取  2
//Max    最大值
//Min    最小值
//Pow    Math.pow(x,y)  x 的 y 次幂的值。
//round   约数
//Sqrt    平方根
//random  随机数
 
   function changColor(){
  
        //  var a=parseFloat(prompt("请输入第一个数","1")) 
        // var b=parseFloat(prompt("请输入第二个数","1") )
        //  var max=Math.max( a,b)   //返回最大值  
        //  document.getElementById ("mess").innerText="最大的数为:"+max

        //  var temp=Math.ceil (a);  // 向上取值
        //  var t=Math.floor(b)      //向下取值
        //  document.getElementById ("mess").innerText="结果:"+temp+":"+t


        //  var t=Math.ceil (Math.random() *10) // 随机数
        //  Math.PI
        //  var t=Math.pow(2,3)  // Math.pow(x,y)  x 的 y 次幂的值。

        //  var t=Math.round (3.6) //四舍五入
        // document.getElementById ("mess").innerText="结果:"+t
      


         var red=Math.ceil (Math.random() *255) // 随机数
        
         var green=Math.ceil (Math.random ()*255)

         var blue=Math.ceil (Math.random ()*255)  
        
        // alert(red.toString(16))   //转为 16进制
        
         var color="#"+red.toString(16)+green.toString(16)+blue.toString(16)
        
         document.getElementById ("content").style.color =color  //修改样式表 颜色
 
          document.getElementById ("content").style.fontSize   =20
          document.getElementById ("content").style.fontWeight    ="bold"
 
    }
     
     
    
   </script>

</head>

<body>
<p id="content">我要变颜色</p>
<input type="button" value="变换颜色" onclick ="changColor()"/>

<span id="mess"></span>


</body>


</html>

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
一篇文章带你了解JavaScript math(上篇)
AS3.0--数学函数
Math:用于数学运算的类
JS浮点运算 加减乘除
软件测试学习教程—JavaScript内置对象
Python笔记:基础知识(二)-2018.9.19
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服