2016-09-29 84 views
-5

我有两个div与不同的数据。我想在盘旋时将其替换为其他div。更换div悬停(div翻转)

我可以在CSS中做到这一点,但我的数据有图像和链接。所以我用图像中的CSS我不能把

<a href=""></a>

上的图像。 我也有4个不同的图像在潜水。 所以我想,当使用悬停该地区我的第一个div应该被替换为第二个div。

谢谢

+2

请出示你的代码。我们无法调试我们无法看到的内容。 – Soviut

+0

代码在哪里我们无法读懂您的想法! – SAM

回答

0

没有给出所以我假设的例子。

HTML

<div id="div1">Some data</div> 
<div id="div2" style="display:none;">Some other data</div> 

的JavaScript(用jQuery)

$("#div1").on('mouseover', function() { 
    $("#div2").show(); 
    $(this).hide(); 
}); 

这不是测试,因此尝试一下一个看它是否你想要做什么。

0

如果你不想使用javacript,你可以这样做。

您可以更改div的内容。

.child-one{ 
 
    display : block; 
 
} 
 

 
.child-two{ 
 
    display : none; 
 
} 
 

 
.parent:hover .child-one{ 
 
    display : none 
 
}
<div class="parent"> 
 
    <div class="child-one"> 
 
    text of child one 
 
    </div> 
 
    <div class="child-two"> 
 
    text of child two 
 
    </div> 
 
</div>