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 回答