【问题标题】:Mouseover effect to change a center div when mousing over other divs鼠标悬停在其他 div 上时更改中心 div 的鼠标悬停效果
【发布时间】:2011-04-19 08:21:51
【问题描述】:

我想制作一个带有直接中心图像的 div 的页面,当用户将鼠标悬停在其他 div 上时(整个事情,而不仅仅是链接),我想改变图像。

是否需要为此使用javascript?什么是最简单的解决方案(onmouseover?)。我不太了解javascript。有没有一个很好的教程,我用谷歌搜索但找不到任何关于 div 交换的东西。

谢谢!

【问题讨论】:

    标签: javascript css html mouseover


    【解决方案1】:

    您可以为此使用 jquery 函数...参考这里 mouseovermouseout

    【讨论】:

      【解决方案2】:

      我在这里包含了一些示例源代码....

      在这里你必须将图像名称和位置 () 替换为相对于你的本地系统。

      <html>
      <head>
      <title>Detecting browser close in IE</title>
      <script type="text/javascript">
      function changeImg()
      {
      document.getElementById("image").src="new image location here";
      }
      
      </script>
      </head>
      </script>
      </head>
      <body >
      <div align="center">
      <img src="imagelocation here" alt="myclass" id="image" />
      </div>
      <div id="div2" align="left" onmouseover="changeImg()">
      Drag Ur mouse to  change image
      </div>
      
      </body>
      </html>
      

      希望对你有帮助。

      【讨论】:

      • 酷。谢谢。我感到困惑的一件事是做多个 div,我将不得不做几个不同的功能吗?或者有没有办法让一个函数用 5+ 个不同的 div 改变一个图像?有没有办法通过括号部分传递图像URL?
      猜你喜欢
      • 1970-01-01
      • 2014-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多