ある画像を別の画像にフェードすることはできません。無地の背景色などのプロパティのみです。
できることは、画像を含む要素の不透明度をフェードすることです。
この方法を使用して、必要な効果を得るために必要なことは、2 つの画像を重ねることです。
次に、一方をフェードインしながら他方をフェードアウトできます。
次のようなものです:
// write a little function to do a toggling fade
jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);
};
// make sure one layer is marked as active and shown and the other is hidden
$("#layer1").show();
$("#layer2").addClass('inactive').hide();
// then you can do this:
$("#button01").click(function () {
$("#layer1").fadeToggle('slow').toggleClass('inactive');
$("#layer2").fadeToggle('slow').toggleClass('inactive');
// then set the new background image for the hidden layer
$(".inactive").css({backgroundImage : 'url(image/staff/shinji.jpg)' } );
};
おそらく美しい方法ではありませんが、うまくいくはずだと思います。