0

個別のファイルであるHTMLページがたくさんありますが、それぞれの間に単純なフェードイン/アウトが必要です。

私は次のコードを使用しました:

$("#content").css("display", "none");

$("#content").fadeIn(2000);

$("ul.menu li a").click(function(event){
    event.preventDefault();
    linkLocation = this.href;
    $("#content").fadeOut(1000, redirectPage);      
});

function redirectPage() {
    window.location = linkLocation;
}

この段階でメイン メニューにバインドしました。コンテンツはヘッダーとフッターの間の div です (エフェクトを適用したくない)。

しかし、これの問題は、少しちらつき、さらにコンテンツが消えてから再びフェードインする前に短時間表示されることです.

これに対するより良い/より簡単な解決策はありますか?

4

1 に答える 1

0

このコードを試してください:

$("#content").css("display", "none");

$("#content").fadeIn(2000);

$("ul.menu li a").click(function(event){
    event.preventDefault();
    linkLocation = this.href;
    $("#content").fadeOut(1000, redirectPage);      
});

function redirectPage() {
    $("#content").css('visibility' : 0); // use to remove the content - it won't be diplayed
    window.location = linkLocation;
}
于 2013-01-11T09:12:05.080 に答える