<DOCTYPE HTML><html> <head> <title>图片切换</title> <style> .div{ width:1000px; height:500px; border:2px solid red; } #image{ width:500px; height:500px; } </style> </head> <body> <script type="text/javascrpt"> function imageChange(number){ var image=document.getElementById("image"); var number=parseInt((Math.random()*9+1)); switch(number){ case 1: image.innerHTML="<img src=1.jpg>"; break; case 2: image.innerHTML="<img src=2.jpg>"; break; case 3: image.innerHTML="<img src=3.jpg>"; break; case 4: image.innerHTML="<img src=4.jpg>"; break; case 5: image.innerHTML="<img src=5.jpg>"; break; case 6: image.innerHTML="<img src=6.jpg>"; break; case 7: image.innerHTML="<img src=7.jpg>"; break; case 8: image.innerHTML="<img src=8.jpg>"; break; case 9: image.innerHTML="<img src=9.jpg>"; break; } } </script> <div class="div"> <div id="image"> </div> <input type="button" value="随机图像" onClick="imageChange(9)"> </div> </body></html>
添加回答
举报
0/150
提交
取消