Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.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
Javascript 滑块不显示所有图像_Javascript_Html_Css_Slideshow_Uislider - Fatal编程技术网

Javascript 滑块不显示所有图像

Javascript 滑块不显示所有图像,javascript,html,css,slideshow,uislider,Javascript,Html,Css,Slideshow,Uislider,我不知道为什么我的滑块按钮不工作,他们没有显示所有的图像太…bruhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh &10094 &10095 还有java脚本 var index = 1; function plusIndex(n){ index = index + n; showImage(index); }

我不知道为什么我的滑块按钮不工作,他们没有显示所有的图像太…bruhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

&10094 &10095

还有java脚本

        var index = 1;

        function plusIndex(n){
            index = index + n;
            showImage(index);
        }


        showImage(index);

        function showImage(n){
            var i;
            var x = document.getElementsByClassName("slides");
            if(n > x.length){
                index = 1;
            }
            if(n < x.length){
                index = x.length;
            }
            for(i=0; i<x.length;i++){
                x[i].style.display = "none";
            }
            x[index-1].style.display = "block";
        }
以下是解决方案-

您只需要更改n var指数=1; 函数plusIndexn{ 指数=指数+n; showImageindex; } showImageindex; 函数showImagen{ var i; var x=document.getelementsbyclassnamelides; 如果n>x.length{ 指数=1; } 如果n
        var index = 1;

        function plusIndex(n){
            index = index + n;
            showImage(index);
        }


        showImage(index);

        function showImage(n){
            var i;
            var x = document.getElementsByClassName("slides");
            if(n > x.length){
                index = 1;
            }
            if(n < x.length){
                index = x.length;
            }
            for(i=0; i<x.length;i++){
                x[i].style.display = "none";
            }
            x[index-1].style.display = "block";
        }