1、JavaScript生成随机数
1.1 JavaScript代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JavaScript生成随机数</title>
</head>
<body>
<img src="" id="myimage" />
</body>
<script type="text/javascript">
var arr = ['a.png', 'b.png', 'c.png', 'd.png'];
var key = Math.floor(Math.random() * arr.length);
var myimg = document.getElementById('myimage');
myimg.src = arr[key];
</script>
</html>