标签:
<div id="console">在线交易平台的成功秘诀:从 Ebay 到 Yelp 到 Uber</div> <script type="text/javascript"> var consoleDom = document.getElementById("console"); consoleDom.style.color = randomColor1(); //获取rgb类型的颜色 IE7不支持 function randomColor(){ var r = Math.floor(Math.random()*256); var g = Math.floor(Math.random()*256); var b = Math.floor(Math.random()*256); return "rgb("+r+","+g+","+b+")"; } //获取十六进制颜色 function randomColor1(){ var r = Math.floor(Math.random()*256); var g = Math.floor(Math.random()*256); var b = Math.floor(Math.random()*256); if(r < 16){ r = "0"+r.toString(16); }else{ r = r.toString(16); } if(g < 16){ g = "0"+g.toString(16); }else{ g = g.toString(16); } if(b < 16){ b = "0"+b.toString(16); }else{ b = b.toString(16); } return "#"+r+g+b; } /* 进制转换 Number.toString(2); 转换成2\8\10\16 */ function test(){ //console.log(new Number(15).toString(16)); } //test(); </script>
标签:
原文地址:http://www.cnblogs.com/sun-rain/p/4806687.html