javascript4位随机数(字体都有颜色)

Posted 赵晓龙

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript4位随机数(字体都有颜色)相关的知识,希望对你有一定的参考价值。

<html>
<head>
<title>随机转换</title>
</head>
<body>

<script type="text/javascript">


var a = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","g","k","l","m","n","o","p","q","r","s","t","u","v","w","s","y","z")
var suiji=Math.floor(Math.random()*a.length);
var suiji1=Math.floor(Math.random()*a.length);
var suiji2=Math.floor(Math.random()*a.length);
var suiji3=Math.floor(Math.random()*a.length);

var yanse1=Math.floor(Math.random()*255);
var yanse2=Math.floor(Math.random()*255);
var yanse3=Math.floor(Math.random()*255);
document.write("<span style=color:rgb("+yanse1+","+yanse2+","+yanse3+")>"+a[suiji]+"</span>"+"<span style=color:rgb("+yanse3+","+yanse2+","+yanse1+")>"+a[suiji1]+"</span>"+"<span style=color:rgb("+yanse2+","+yanse3+","+yanse1+")>"+a[suiji2]+"</span>"+"<span style=color:rgb("+yanse3+","+yanse2+","+yanse1+")>"+a[suiji3]+"</span>")

// document.write("随机数:"+a[suiji]+a[suiji1]+a[suiji2]+a[suiji3])
</script>
</body>
</html>


















以上是关于javascript4位随机数(字体都有颜色)的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript4种数组随机选取实战源码

JavaScript4种数组随机选取实战源码

如何用js解决字体颜色随机变换?

php怎么随机高亮其中一个数组的字体颜色?

随机颜色和动态改变字体大小

win 7 64位安装后网页标签字体颜色偏黄偏红。