其他分享
首页 > 其他分享> > 随机获取数组元素

随机获取数组元素

作者:互联网

如题,不废话了,直接代码走起

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script language="javascript">
			window.onload = function() {
				var arr = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
				for(var i = 0; i <= 10; i++) {
					var index = Math.floor((Math.random() * arr.length));
					document.write(arr[index] + ",");
				}
			}
		</script>
	</head>
	<body>
	</body>
</html>

 

标签:function,onload,arr,废话,获取,window,随机,数组,var
来源: https://blog.csdn.net/qq_36521848/article/details/106245930