Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
刷新后jQuery滑块不工作_Jquery_Image_Google Chrome_Browser_Slider - Fatal编程技术网

刷新后jQuery滑块不工作

刷新后jQuery滑块不工作,jquery,image,google-chrome,browser,slider,Jquery,Image,Google Chrome,Browser,Slider,我的网站上有一个滑动条。它在Firefox和IE等浏览器中运行良好,但在Google Chrome和Safari中则不行。刷新页面后,图片不会显示。我不知道为什么 我的代码: (function ($) { $.fn.jCarouselLite = function (o) { o = $.extend({ btnPrev: null, btnNext: null, btnGo: null,

我的网站上有一个滑动条。它在Firefox和IE等浏览器中运行良好,但在Google Chrome和Safari中则不行。刷新页面后,图片不会显示。我不知道为什么

我的代码:

(function ($) {
    $.fn.jCarouselLite = function (o) {
        o = $.extend({
            btnPrev: null,
            btnNext: null,
            btnGo: null,
            mouseWheel: false,
            auto: null,
            speed: 500,
            easing: null,
            vertical: false,
            circular: true,
            visible: 3,
            start: 0,
            scroll: 1,
            beforeStart: null,
            afterEnd: null
        }, o || {});
        return this.each(function () {
            var b = false,
                animCss = o.vertical ? "top" : "left",
                sizeCss = o.vertical ? "height" : "width";
            var c = $(this),
                ul = $("ul", c),
                tLi = $("li", ul),
                tl = tLi.size(),
                v = o.visible;
            if (o.circular) {
                ul.prepend(tLi.slice(tl - v - 1 + 1).clone()).append(tLi.slice(0, v).clone());
                o.start += v
            }
            var f = $("li", ul),
                itemLength = f.size(),
                curr = o.start;
            c.css("visibility", "visible");
            f.css({
                overflow: "hidden",
                float: o.vertical ? "none" : "left"
            });
            ul.css({
                margin: "0",
                padding: "0",
                position: "relative",
                "list-style-type": "none",
                "z-index": "1"
            });
            c.css({
                overflow: "hidden",
                position: "relative",
                "z-index": "2",
                left: "23px"
            });
            var g = o.vertical ? height(f) : width(f);
            var h = g * itemLength;
            var j = g * v;
            f.css({
                width: f.width(1050),
                height: f.height(290)
            });
            ul.css(sizeCss, h + "px").css(animCss, -(curr * g));
            c.css(sizeCss, j + "px");
            if (o.btnPrev) $(o.btnPrev).click(function () {
                return go(curr - o.scroll)
            });
            if (o.btnNext) $(o.btnNext).click(function () {
                return go(curr + o.scroll)
            });
            if (o.btnGo) $.each(o.btnGo, function (i, a) {
                $(a).click(function () {
                    return go(o.circular ? o.visible + i : i)
                })
            });
            if (o.mouseWheel && c.mousewheel) c.mousewheel(function (e, d) {
                return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll)
            });
            if (o.auto) setInterval(function () {
                go(curr + o.scroll)
            }, o.auto + o.speed);

            function vis() {
                return f.slice(curr).slice(0, v)
            };

            function go(a) {
                if (!b) {
                    if (o.beforeStart) o.beforeStart.call(this, vis());
                    if (o.circular) {
                        if (a <= o.start - v - 1) {
                            ul.css(animCss, -((itemLength - (v * 2)) * g) + "px");
                            curr = a == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll
                        } else if (a >= itemLength - v + 1) {
                            ul.css(animCss, -((v) * g) + "px");
                            curr = a == itemLength - v + 1 ? v + 1 : v + o.scroll
                        } else curr = a
                    } else {
                        if (a < 0 || a > itemLength - v) return;
                        else curr = a
                    }
                    b = true;
                    ul.animate(animCss == "left" ? {
                        left: -(curr * g)
                    } : {
                        top: -(curr * g)
                    }, o.speed, o.easing, function () {
                        if (o.afterEnd) o.afterEnd.call(this, vis());
                        b = false
                    });
                    if (!o.circular) {
                        $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
                        $((curr - o.scroll < 0 && o.btnPrev) || (curr + o.scroll > itemLength - v && o.btnNext) || []).addClass("disabled")
                    }
                }
                return false
            }
        })
    };

    function css(a, b) {
        return parseInt($.css(a[0], b)) || 0
    };

    function width(a) {
        return a[0].offsetWidth + css(a, 'marginLeft') + css(a, 'marginRight')
    };

    function height(a) {
        return a[0].offsetHeight + css(a, 'marginTop') + css(a, 'marginBottom')
    }
})(jQuery);
(函数($){
$.fn.jCarouselLite=函数(o){
o=$.extend({
btnPrev:null,
btnNext:null,
btnGo:null,
鼠标滚轮:错,
自动:空,
速度:500,,
参数:null,
垂直:假,
通告:对,,
可见:3,
起点:0,
卷轴:1,
beforeStart:null,
尾声:空
},o |{});
返回此。每个(函数(){
var b=假,
animCss=o.垂直?“顶部”:“左侧”,
sizeCss=o.垂直?“高度”:“宽度”;
var c=$(此),
ul=$(“ul”,c),
tLi=$(“li”,ul),
tl=tLi.size(),
v=可见光;
若有(o.通告){
prepend(tLi.slice(tl-v-1+1.clone()).append(tLi.slice(0,v.clone());
o、 开始+=v
}
var f=$(“li”,ul),
itemLength=f.size(),
curr=o.start;
c、 css(“可见性”、“可见”);
f、 css({
溢出:“隐藏”,
浮动:o.垂直?“无”:“左”
});
ul.css({
边距:“0”,
填充:“0”,
职位:“相对”,
“列表样式类型”:“无”,
“z索引”:“1”
});
c、 css({
溢出:“隐藏”,
职位:“相对”,
“z指数”:“2”,
左:“23px”
});
var g=垂直?高度(f):宽度(f);
var h=g*itemLength;
var j=g*v;
f、 css({
宽度:f.宽度(1050),
高度:f.高度(290)
});
ul.css(sizeCss,h+“px”).css(animCss,-(curr*g));
c、 css(sizeCss,j+“px”);
如果(o.btnPrev)$(o.btnPrev)。单击(函数(){
返回go(当前-o.scroll)
});
如果(o.btnNext)$(o.btnNext)。单击(函数(){
返回go(当前+o.滚动)
});
if(o.btnGo)$。每个(o.btnGo,函数(i,a){
$(a)。单击(函数(){
返回go(o.圆形?o.可见+i:i)
})
});
如果(o.鼠标滚轮和c.鼠标滚轮)c.鼠标滚轮(功能(e,d){
返回d>0?前进(当前-运行滚动):前进(当前+运行滚动)
});
if(o.auto)设置间隔(函数(){
前进(当前+前进滚动)
},o.自动+o.速度);
函数vis(){
返回f.slice(当前).slice(0,v)
};
功能go(a){
如果(!b){
if(o.beforeStart)o.beforeStart.call(this,vis());
若有(o.通告){
如果(a=itemLength-v+1){
ul.css(animCss,((v)*g)+“px”);
curr=a==itemLength-v+1?v+1:v+o
}else curr=a
}否则{
如果(a<0 | | a>itemLength-v)返回;
else curr=a
}
b=正确;
动画(animCss==“左”{
左:-(当前*克)
} : {
顶部:-(当前*克)
},o.速度,o.放松,功能(){
如果(o.afterEnd)o.afterEnd.call(this,vis());
b=错误
});
如果(!o.圆形){
$(o.btnPrev+”,“+o.btnNext).removeClass(“已禁用”);
$((curr-o.scroll<0&&o.btnPrev)| | |(curr+o.scroll>itemLength-v&&o.btnNext)| |【】)。addClass(“已禁用”)
}
}
返回错误
}
})
};
函数css(a,b){
返回parseInt($.css(a[0],b))| | 0
};
功能宽度(a){
返回一个[0]。offsetWidth+css(a'marginLeft')+css(a'marginRight'))
};
功能高度(a){
返回一个[0]。offsetHeight+css(a'marginTop')+css(a'marginBottom'))
}
})(jQuery);

谢谢

检查浏览器的控制台是否有任何错误(Ctrl+Shift+J)控制台没有显示任何内容。图像正在加载,但不可见。刷新页面是什么意思?您如何知道图像正在加载?您是否使用浏览器的检查工具来分析CSS?问题已解决。已更改:$(文档).load(函数(){}到$(窗口).load(函数(){})。我不知道为什么,但它的工作!谢谢您的帮助!