jQuery load()不起作用

jQuery load() doesn't work

本文关键字:不起作用 load jQuery      更新时间:2023-09-26

我的问题与加载事件是,当我测试页面它不工作(不隐藏预加载器图像),但当我把函数在.ready(),该函数工作(它隐藏)。

下面是代码: JAVASCRIPT:

$(document).load(function(){
    $("#loaderHolder").hide("fast");
});
$(document).ready(function(){
    $('#slider').cycle();
    $('.sf-menu').superfish({
        autoArrows: false
    });
    $('.scroll').slimScroll({
        height: '590px',
        wheelStep:5,
        size:'15px',
        width:'590px',
        position: 'left',
        railColor:'#c5c5c5',
        color:'#a2a1a1',
        railVisible:true,
        alwaysVisible:true,
        distance: '565px'
    });
    $('.scroll').css('width','550px');
    $('.gallery').colorbox();
    $('#gallery img').hover(function(){ $(this).fadeTo(500, 0.3)}, function(){$(this).stop().fadeTo(500, 1)})
    $("#home-link").click(function(){
        if ($(".active").length == 0)
        {
            return ;
        }
        else
        {
            var active = $(".active");
            active.css("display","inline-block");
            active.hide("slide",{},700);
            active.attr("class","vanished");
        }
    });
    $("#about-link").click(function(){
        if ($(".active").length == 0)
        {
            var hidden = $("#about");
            hidden.show("slide",{},700);
            hidden.attr("class","active");
        }
        else
        {
            if ($("#about").attr("class") == "active")
            {
                return ;
            }
            else
            {
                var active = $(".active");
                active.css("display","inline-block");
                active.hide("slide",{},700);
                active.attr("class","vanished");
                var hidden = $("#about");
                hidden.show("slide",{},700);
                hidden.attr("class","active");
            }
        }
    })
    $("#starters-link").click(function(){
        if ($(".active").length == 0)
        {
            var hidden = $("#starters");
            hidden.show("slide",{},700);
            hidden.attr("class","active");
        }
        else
        {
            if ($("#starters").attr("class") == "active")
            {
                return ;
            }
            else
            {
                var active = $(".active");
                active.css("display","inline-block");
                active.hide("slide",{},700);
                active.attr("class","vanished");
                var hidden = $("#starters");
                hidden.show("slide",{},700);
                hidden.attr("class","active");
            }
        }
    })
    $("#gallery-link").click(function(){
        if ($(".active").length == 0)
        {
            var hidden = $("#gallery");
            hidden.show("slide",{},700);
            hidden.attr("class","active");
        }
        else
        {
            if ($("#gallery").attr("class") == "active")
            {
                return ;
            }
            else
            {
                var active = $(".active");
                active.css("display","inline-block");
                active.hide("slide",{},700);
                active.attr("class","vanished");
                var hidden = $("#gallery");
                hidden.show("slide",{},700);
                hidden.attr("class","active");
            }
        }
    })
    $("#contacts-link").click(function(){
        if ($(".active").length == 0)
        {
            var hidden = $("#contacts");
            hidden.show("slide",{},700);
            hidden.attr("class","active");
        }
        else
        {
            if ($("#contacts").attr("class") == "active")
            {
                return ;
            }
            else
            {
                var active = $(".active");
                active.css("display","inline-block");
                active.hide("slide",{},700);
                active.attr("class","vanished");
                var hidden = $("#contacts");
                hidden.show("slide",{},700);
                hidden.attr("class","active");
            }
        }
    })
});

尝试(窗口)美元.load()不(文档)美元.load ()

$(window).load(function () {
  // run code
});

尝试:

$(window).load

代替

$(document).load

我认为$。load是对给定url(第一个参数)实际执行AJAX请求的方法。如果你想在文档上做点什么。加载事件必须使用$(document).ready()