我有一组项目。每个项目都有两张图片和一些文本。对于这些图片,我创建了一个父div,其中包含了一个overflow:hidden的CSS值。我想实现一个鼠标悬停效果。只要你悬停在图片上,我希望隐藏当前的div并显示第二个div。以下是一个小片段:
<div class="product-images">
<div class="product-image-1"><img src="image1.gif>" /></div>
<div class="product-image-2"><img src="images2.gif" /></div>
</div>
我创建了一个小的jQuery代码片段:
jQuery(document).ready(function() {
jQuery('.product-images').mouseover(function() {
jQuery('.product-image-1').hide();
}).mouseout(function() {
jQuery('.product-image-1').show();
});
});
现在的问题不仅是当前鼠标悬停的子元素被隐藏了,而且所有其他现有的子元素也被隐藏了。我需要像"this"或"current"这样的东西,但我不知道哪个jQuery函数是正确的。有什么想法吗?
谢谢,BJ