鼠标悬停以随机更改图像

时间:2018-11-03 22:42:41

标签: javascript onmouseover

当鼠标移动到图像上时,如何使用while循环将初始图像随机更改为其他任何图像(与当前图像不同),如果可能的话,使用数组?

   <!doctype html>
    <html lang="en">
    <head>
      <title> onmouseover event </title>
      <meta charset="utf-8">
      <!-- add in the prototype library -->
      <script src="prototype.js"></script>
      <script src="task1.js"></script>
      <style>
        div {
          width: 75%;
          margin: auto;
          text-align: center;
          font-family: sans-serif;
        }
        img { width: 300px; }
      </style>
    </head>
    <body>
      <div id="div">
      <h1> onmouseover event </h1>
      <p> <img id="myImg" src="image1.png"> </p>

      </div>
    </body>
    </html>
     <script>   
function changeImage() {
    var images = ["image.png", "image2.png", "image3.png", "image4.png"]; </script>

0 个答案:

没有答案