<!doctype html> <html> <head> <title>双色球号码随机生成</title> <script type="text/javascript"> function generateBall(){ var redBall = []; var blueBall; for(var i=0; i<6; i++){ var number = Math.floor(Math.random() * 33 + 1); if(redBall.indexOf(number) !== -1){ i--; } else{ redBall.push(number); } } blueBall = Math.floor(Math.random() * 16 + 1); redBall.sort(function(a,b){ return a-b; }); document.getElementById('result').innerHTML = '红球:' + redBall + ' 蓝球:' + blueBall; } </script> </head> <body> <div> <h1>双色球号码随机生成</h1> <input type="button" value="生成号码" onclick="generateBall();"> <p id="result"></p> </div> </body> </html>标签:WEB,双色球,号码,生成,随机,var,chatgpt From: https://www.cnblogs.com/gougouwang/p/17133366.html