我目前正在使用代码将图像的 mouseenter 上的不透明度设置为 1,然后在 mouseleave 上再次设置为 0。它不是显示一个图像,而是在悬停时显示所有图像。
我试过使用(this)
而不是,(.project-hover img)
所以它只影响那个特定的 div,但我需要定位(.project-hover img)
而不是.span4
启动函数的目标。
我将如何实现这一目标?
$(document).ready(function() {
$(".span4").on("mouseenter", function() {
$('.project-hover img').stop();//halts previous animation if it's running
$('.project-hover img').animate({
opacity: 1
});
}).on("mouseleave", function() {
$('.project-hover img').stop();
$('.project-hover img').animate({
opacity: 0
});
});
});
HTML
<div class="span4">
<div class="wrap-title">
<div class="position">
<div class="title"><a href="<?php echo get_permalink(); ?>"><?php the_title();?></a></div>
<div class="tags"><?php echo $cats; ?> </div>
</div>
</div>
<div class="project-hover"><img src="<?php echo catch_that_image(); ?>"> </div>
</div>