<img src="2.jpg" width="200px" height="100px">.
<img src="3.jpg" width="200px" height="100px">.
........
<img src="9.jpg" width="200px" height="100px">.
<div id="picdiv">//4张小图片
<img src="" width="100px" height="50px">.
<img src="" width="100px" height="50px">.
<img src="" width="100px" height="50px">.
<img src="" width="100px" height="50px">.
</div>
<script>
var num1=Math.floor(Math.random()*9)
var num2=Math.floor(Math.random()*9)
var num3=Math.floor(Math.random()*9)
var num4=Math.floor(Math.random()*9)
var myDiv=document.getEllementById('picdiv')
var pic=myDiv.getElementsByTagName('img')
pic[0].src=num1+".jpg"
pic[1].src=num1+".jpg"
pic[2].src=num1+".jpg"
pic[3].src=num1+".jpg"
</script>
var arr = [1,2,3,4,5,6,7,8,9,10]var result = new Array(3)
for(var i = 0 i < result.length i++){
result[i] = arr.splice(Math.random()*arr.length>>>0, 1)[0]
}
console.info(result)