【发布时间】:2011-04-19 08:21:51
【问题描述】:
我想制作一个带有直接中心图像的 div 的页面,当用户将鼠标悬停在其他 div 上时(整个事情,而不仅仅是链接),我想改变图像。
是否需要为此使用javascript?什么是最简单的解决方案(onmouseover?)。我不太了解javascript。有没有一个很好的教程,我用谷歌搜索但找不到任何关于 div 交换的东西。
谢谢!
【问题讨论】:
标签: javascript css html mouseover
我想制作一个带有直接中心图像的 div 的页面,当用户将鼠标悬停在其他 div 上时(整个事情,而不仅仅是链接),我想改变图像。
是否需要为此使用javascript?什么是最简单的解决方案(onmouseover?)。我不太了解javascript。有没有一个很好的教程,我用谷歌搜索但找不到任何关于 div 交换的东西。
谢谢!
【问题讨论】:
标签: javascript css html mouseover
我在这里包含了一些示例源代码....
在这里你必须将图像名称和位置 () 替换为相对于你的本地系统。
<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>
希望对你有帮助。
【讨论】: