两个jquery脚本冲突

发布于 2024-11-30 23:35:19 字数 1891 浏览 3 评论 0原文

我在向我的网站添加灯箱脚本时遇到了麻烦,这是因为我正在使用本教程中的代码 http://tutorialzine.com/2010/11/apple-style-splash-screen-jquery/ 在我的网站的开头,因此它会在进入时加载动画该网站,但是 `

$(document).ready(function(){

    // Calling our splashScreen plugin and
    // passing an array with images to be shown

    $('#promoIMG').splashScreen({
        textLayers : [
            'img/thinner.png',
            'img/more_elegant.png',
            'img/our_new.png'
        ]
    });
});

上面的代码取消了我从此处找到的灯箱脚本中使用的任何内容: http:// /leandrovieira.com/projects/jquery/lightbox/#

如何让两者协同工作?

我将它们添加到我的标题中,如下所示(它在 WordPress 中):

<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<link rel="shortcut icon" href="<?php bloginfo('stylesheet_directory'); ?>/favicon.ico" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/Javascript/jquery.splashscreen.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/Javascript/script.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/Javascript/lightbox/js/jquery.lightbox-0.5.js"></script>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/Javascript/lightbox/css/jquery.lightbox-0.5.css" media="screen" />

    <script type="text/javascript">

    $(function() {
        $('#sidebar-menu a').lightBox();
    });
    </script>

任何建议都可以!

I'm having truble adding a lightbox script to my site, it's because i'm using the code from this tutorial http://tutorialzine.com/2010/11/apple-style-splash-screen-jquery/ at the start of my site, so it loads an animation upon entering the site, however `

$(document).ready(function(){

    // Calling our splashScreen plugin and
    // passing an array with images to be shown

    $('#promoIMG').splashScreen({
        textLayers : [
            'img/thinner.png',
            'img/more_elegant.png',
            'img/our_new.png'
        ]
    });
});

The above code cancels out anything i use from the lightbox script found here: http://leandrovieira.com/projects/jquery/lightbox/#

How do I get the two to work together?

I'm adding them to my header as follows (it's within wordpress):

<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<link rel="shortcut icon" href="<?php bloginfo('stylesheet_directory'); ?>/favicon.ico" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/Javascript/jquery.splashscreen.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/Javascript/script.js"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/Javascript/lightbox/js/jquery.lightbox-0.5.js"></script>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/Javascript/lightbox/css/jquery.lightbox-0.5.css" media="screen" />

    <script type="text/javascript">

    $(function() {
        $('#sidebar-menu a').lightBox();
    });
    </script>

Any suggestions will do!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飞烟轻若梦 2024-12-07 23:35:19

您应该向启动屏幕插件添加一个回调,以在完成后初始化灯箱。

回调应该在关闭spash的点击事件上执行

 splashScreen.click(function(){
    console.log('click event');
    splashScreen.fadeOut('slow', function(){
        console.log('callback 1');
        if(settings.finished != null) settings.finished();
    });    
});

,然后在创建对象时传递回调

$('#promoIMG').splashScreen({
    textLayers : [
        'img/thinner.png',
        'img/more_elegant.png',
        'img/our_new.png'
    ],
    finished: function(){
         console.log('callback 2');
         $('#sidebar-menu a').lightBox();                 
    }
});

编辑添加condole.log以查看实际到达的代码。

you should add a callback to the splash screen plugin to initialize lightbox once it's finished.

the callback should be executed on the click event which closes the spash

 splashScreen.click(function(){
    console.log('click event');
    splashScreen.fadeOut('slow', function(){
        console.log('callback 1');
        if(settings.finished != null) settings.finished();
    });    
});

then pass the callback when creating the object

$('#promoIMG').splashScreen({
    textLayers : [
        'img/thinner.png',
        'img/more_elegant.png',
        'img/our_new.png'
    ],
    finished: function(){
         console.log('callback 2');
         $('#sidebar-menu a').lightBox();                 
    }
});

EDIT add the condole.log's to see what code actually gets reached.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文