うまくいけば、私のコードがそれ自体を物語っていると思います。
要素にカーソルを合わせると、現在ホバーされている要素ではなく、同じクラスのすべての要素に対して each 関数を実行したい:
$(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');
更新、この新しいコードは私が今したいことをします...
$(".%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');