0
我有一個導航欄與圖像需要翻轉,但他們是tranparent PNG。背景紋理如此透明PNG是必須的。我這樣做:透明PNG圖像交換與淡入淡出jquery
$('.fade').each(function() {
var std = $(this).attr("src");
var hover = std.replace(".png", "_over.png");
$(this).wrap('<div />').clone().insertAfter(this).attr('src', hover).removeClass('fadein').siblings().css({
position:'absolute'
});
$(this).mouseenter(function() {
$(this).stop().fadeTo(600, 0);
}).mouseleave(function() {
$(this).stop().fadeTo(600, 1);
});
});
其中被張貼在這裏的解決方案: A better implementation of a fading image swap with javascript/jQuery
它的工作原理,但麻煩的是「褪色爲」 PNG(這只是一個陰影)可以在看到頁面加載,因爲它應該在主圖像後面: http://jsfiddle.net/qykwV/
我可以隱藏'_over.png'圖像,而不是將它放在第一個後面嗎?