JQuery fades away all other images

I made this code with jQuery to fade out the images ( but not one ) and all the images will disappear at the same time!

$(".playThumb").fadeTo("normal", 1);

$(".playThumb").hover(function() {
    $(".playThumb").each(function() {
        if ( $(this) != $(this) ) {
            $(this).fadeTo("fast", 0.3);
        }
    });
}, function() {
    $(".playThumb").each(function() {
            $(this).fadeTo("fast", 1);
    });
});

<a href="#"><img src="001.jpg" class="playThumb" />
<a href="#"><img src="002.jpg" class="playThumb" />
<a href="#"><img src="003.jpg" class="playThumb" />
<a href="#"><img src="004.jpg" class="playThumb" />

If someone can help me put out all the other images except the ones that I mouse over ?

+5
source share
1 answer

You can use notto filter a hovering element:

$(".playThumb").fadeTo("normal", 1);

$(".playThumb").hover(function() {
    $(".playThumb").not(this).fadeTo("fast", 0.3);
}, function() {
    $(".playThumb").not(this).fadeTo("fast", 1);
});
+16
source

All Articles