鼠标悬停效果在鼠标悬停在其他div上时更改中心div

时间:2011-04-19 08:21:52

标签: javascript css html mouseover

我想在直接中心创建一个带有图像的div的页面,当用户将鼠标悬停在其他div(整个事物,而不仅仅是链接)时,我想让图像发生变化。

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

谢谢!

2 个答案:

答案 0 :(得分:0)

您可以使用jquery函数...请参阅此处   mouseovermouseout

答案 1 :(得分:0)

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

这里你必须将图像名称和位置()替换为Ur本地系统。

<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>

我希望这会有助于你。