I have a gallery with pictures and on mouseover on 1 picture I'd like to do sth with all the OTHER pictures (so all pictures having the class .picture, except the one hovering ($(this)).
I tried to apply a class to all pictures with the class .picture and then removing this added class on the picture hovering, and then using the added class (which contains the right pictures then), but it is not working smoothly...
Is there any cleaner and better way to do this?
Example:
pic 1 -> do sth with this
pic 2 -> do sth with this
pic 3 -> gets hovered, don't do anything with this, exclude it from the selection!
Use .not.
$('.picture').not(this);
var img = $('.picture');
img.on('hover', function() {
img.not(this).each(function() {
/* do Something with $(this); */
})
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With