1

ユーザーがサイトにアクセスするとフェードインするメインコンテナの上に配置される基本的なイメージがあります。このイベントは初期ロード時にのみ発生するようにします。これは達成できますか?

これが.jsです

    <script type="text/javascript">
    $(document).ready(function () {
        $('#landing').animate({opacity: 0.01}, 5000, function () {
            $(this).hide();
            $('#main').children().fadeIn(5000);
        });   
    });
</script>

前もって感謝します!

4

1 に答える 1

4

Cookieを設定してから、Cookieが設定されていない場合にのみアニメーションを実行できます。

jQueryを使用する場合は、次のjQueryプラグインを使用することをお勧めします: https ://github.com/carhartl/jquery-cookie

そして、次のようなことをします。

if (!$.cookie('intro_animation')) {
    $.cookie('intro_animation', 'true');

    // Do your animation
    $('#landing').animate({opacity: 0.01}, 5000, function () {
        $(this).hide();
        $('#main').children().fadeIn(5000);
    }); 
}
于 2012-12-15T15:19:29.897 に答える