javascript 随机点名

来源:互联网 发布:nba球员数据排名 编辑:程序博客网 时间:2024/04/30 22:31
<html>
<head>
<script type="text/javascript">
//随机点名
var a=['张三','李四','王五'];
//随机获得数组的下标
var b=Math.round(Math.random()*(a.length-1));
//获得数组的数值
alert (a[b]);
</script>
</head>
</html>