Reputation: 2807
I think hopefully my code will speak for its self.
When i hover over an element, i want to run an each function on all elements of the same class, but not the currently hovered element:
$(document).on({
mouseenter: function () {
$('#%id% .imageStyle').each(function(){
if($(this) != $(this)){ // obviously this line is incorrect
// I only want to execute this if the current each iteration is not the element I am hovering over
$.this.pixastic("desaturate");
}
});
Pixastic.revert(this);
},
mouseleave: function () {
$(this).pixastic("desaturate");
}
}, '#%id% .imageStyle');
Update, this new code does what I want now...
$(".%id%desaturate img").addClass("sprightly");
$(document).on({
mouseenter: function () {
$('.sprightly').not(this).each(function(){
if($(this).is("img")){
$(this).trigger("mouseleave");
}
});
Pixastic.revert(this);
},
mouseleave: function () {
$(this).pixastic("desaturate");
}
}, '#%id% .imageStyle');
Upvotes: 0
Views: 63
Reputation: 4675
Updated
There is no need to use the each function, since .pixastic()
will apply for all elements matched by the selector. Try this out, i have not tested it
$("#container").on({
mouseenter: function () {
$('#container .imageStyle').not(this).pixastic("desaturate");
Pixastic.revert(this);
},
mouseleave: function () {
$(this).pixastic("desaturate");
}
}, '.imageStyle');
Upvotes: 2