我在wordpress上的特色图像上使用.fadeTo()jQuery效果.我如何设置代码是如果鼠标悬停在图像上,它会渐变到0.7,当鼠标离开时,它会逐渐消失为1:
jQuery(function($) {
$(window).load(function() {
$('.image').mouseover(function() {
$('.image').fadeTo('fast', 0.7);
});
$('.image').mouseout(function() {
$('.image').fadeTo('fast', 1);
});
});
Run Code Online (Sandbox Code Playgroud)
});
给出的类是".image",我把它放在wordpress循环中的div中,特色图像代码就像这样:
<div class="image"><?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?> <!-- If has featured image, GET --></div>
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,每当我将鼠标悬停在单张图像上时,它会淡化页面上的所有图像.我真正想要的是让它淡化鼠标悬停的图像,我做错了什么?