views:

403

answers:

1

Hi, I made this code with jQuery to fade images (but not the one a move the mouse over) and all images fade 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 to fade all other images except the one I point the mouse over ?

+11  A: 

You could use not to filter out the element being hovered:

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

$(".playThumb").hover(function() {
    $(".playThumb").not(this).fadeTo("fast", 0.3);
}, function() {
    $(".playThumb").not(this).fadeTo("fast", 1);
});
moff
pretty sure you don't need $() around "this" in the not.
Paolo Bergantino
Ok, I've removed the $() now.
moff