标签:text set w3c ansi www round nal i++ var
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>操作css样式【js】</title> <script type="text/javascript"> function createCode(){ var datas = ["请", "叫", "我", "木", "丁", "西", "随", "机", "码"]; // var randomNum = Math.floor(Math.random()*(7-2+1) + 2);//2-7随机数(包括边界) // var randomNum = Math.floor(Math.random()*(4-2) + 2);//2-3(包括边界) // var randomNum = Math.random()*2 + 2;//2点几到3点几(不包括边界2、4) var randomNum = Math.round((Math.random()*(7-2) + 2)*10)/10;//2点几到7(最多保留一位小数) alert(randomNum); //产生4个随机数 /* for(var i=0; i<4; i++){ var randomIndex = Math.floor(Math.random()*datas.length);//0-8随机数(包括);Math.random(); 0-1(不包括边界);Math.floor()向下取整 //alert(randomIndex); }*/ } </script> </head> <body> <a href="#" onclick="createCode()">看不清,再来一个</a> </body> </html>
标签:text set w3c ansi www round nal i++ var
原文地址:http://www.cnblogs.com/itMiracle/p/6014153.html