<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>随机数组</title> </head> <body> <div id="demo"></div> <script type="text/javascript"> var obj=document.getElementById(‘demo‘); var numArray=[‘134‘,‘236‘,‘666‘,‘888‘,‘999‘]; var numLength=numArray.length;//获取数组长度 var sj=Math.random()*numLength;//随机 var i=Math.floor(sj);//取整 obj.innerHTML=numArray[i];//取出数组里下标 </script> </body> </html>