1. 程式人生 > >javascript4位隨機數(字體都有顏色)

javascript4位隨機數(字體都有顏色)

ava dom and array div ext span 字體 col

<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位隨機數(字體都有顏色)