-1

我正在尝试让 2 个 jquery 工作而不会发生冲突!

这是我的代码:

(function($){ //This functions first parameter is named $
    $(document).ready(function(){
        // tabbed boxes
        $('#tabs div').hide();
        $('#tabs div:first').show();
        $('#tabs ul li:first').addClass('active');
        $('#tabs ul li a').click(function(){ 
            $('#tabs ul li').removeClass('active');
            $(this).parent().addClass('active'); 
            var currentTab = $(this).attr('href'); 
            $('#tabs div').hide();
            $(currentTab).show();
            return false;
        });
    });

    $(window).load(function(){
        // jQuery Lightbox
        var lightboxPath = "/js/jquery-lightbox/";
        $("a[rel='group1']").lightBox({
            imageLoading:lightboxPath+"img/lightbox-ico-loading.gif",
            imageBtnPrev:lightboxPath+"img/lightbox-btn-prev.gif",
            imageBtnNext:lightboxPath+"img/lightbox-btn-next.gif",
            imageBtnClose:lightboxPath+"img/lightbox-btn-close.gif",
            imageBlank:lightboxPath+"img/lightbox-blank.gif"
        });

        // Photo gallery > Standard
        $(".photosgallery-std").sliderkit({
            mousewheel:true,
            shownavitems:7,
            //navfx:"none",
            panelbtnshover:true,
            auto:true,
            circular:true,
            navscrollatend:true,
            counter:true
        });
    })
})(jQuery); 

请任何人都可以帮助:)

4

1 回答 1

0

我认为你必须把它放在外面()(jQuery);

$(document).ready(function(){
    // tabbed boxes
    $('#tabs div').hide();
    $('#tabs div:first').show();
    $('#tabs ul li:first').addClass('active');
    $('#tabs ul li a').click(function(){ 
        $('#tabs ul li').removeClass('active');
        $(this).parent().addClass('active'); 
        var currentTab = $(this).attr('href'); 
        $('#tabs div').hide();
        $(currentTab).show();
        return false;
    });
});

(function($){ //This functions first parameter is named $
$(window).load(function(){
    // jQuery Lightbox
    var lightboxPath = "/js/jquery-lightbox/";
    $("a[rel='group1']").lightBox({
        imageLoading:lightboxPath+"img/lightbox-ico-loading.gif",
        imageBtnPrev:lightboxPath+"img/lightbox-btn-prev.gif",
        imageBtnNext:lightboxPath+"img/lightbox-btn-next.gif",
        imageBtnClose:lightboxPath+"img/lightbox-btn-close.gif",
        imageBlank:lightboxPath+"img/lightbox-blank.gif"
    });

    // Photo gallery > Standard
    $(".photosgallery-std").sliderkit({
        mousewheel:true,
        shownavitems:7,
        //navfx:"none",
        panelbtnshover:true,
        auto:true,
        circular:true,
        navscrollatend:true,
        counter:true
    });
});
})(jQuery); 
于 2013-01-16T11:56:04.713 回答