Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.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_Jquery_Css - Fatal编程技术网

对图像进行分页时,javascript中的图像序列错误

对图像进行分页时,javascript中的图像序列错误,javascript,jquery,css,Javascript,Jquery,Css,我在一个网页模板,其中有一个图像画廊的工作,一个活的样本可以显示在下面 现在,我修改了上面最新的工作部分分页,因此如果单击一个图像,该图像显示在jquery滑块中,那么我在图像中添加了一个跨距,如下所示:- function loadImage(src, callback){ var img = $('<img>').on('load', function(){ callback.call(img);

我在一个网页模板,其中有一个图像画廊的工作,一个活的样本可以显示在下面

现在,我修改了上面最新的工作部分分页,因此如果单击一个图像,该图像显示在jquery滑块中,那么我在图像中添加了一个跨距,如下所示:-

        function loadImage(src, callback){
            var img = $('<img>').on('load', function(){
                callback.call(img);
            });

            img.attr('src', src);
 // *******Here is my custom code start ....****
            var allcaptions = $("figure span");


            setTimeout(function () {
                $(".placeholder").each(function (i) {

                    // in each .placeholder, copy its caption's mark-up into it (remove the img first)
                    var caption = allcaptions.eq(i).clone();

                    var t = caption.find("img").attr('data-goto');

                    // caption.append($("<a />", { "text": "test", "href": t }));
                    caption.append("<a href='" + t + "'>test</a>");

                    caption.find("img").remove();
                    $(this).append("<div class='caption'>" + caption.html() + "</div>");
                });
            }, 500
    );
        }
为了实现在jquery滑块内显示跨度,我修改了touch.jquery.js脚本的回调函数,如下所示:-

        function loadImage(src, callback){
            var img = $('<img>').on('load', function(){
                callback.call(img);
            });

            img.attr('src', src);
 // *******Here is my custom code start ....****
            var allcaptions = $("figure span");


            setTimeout(function () {
                $(".placeholder").each(function (i) {

                    // in each .placeholder, copy its caption's mark-up into it (remove the img first)
                    var caption = allcaptions.eq(i).clone();

                    var t = caption.find("img").attr('data-goto');

                    // caption.append($("<a />", { "text": "test", "href": t }));
                    caption.append("<a href='" + t + "'>test</a>");

                    caption.find("img").remove();
                    $(this).append("<div class='caption'>" + caption.html() + "</div>");
                });
            }, 500
    );
        }
以下是jquery滑块内的标记:-


那么有人能帮我转达一下吗?现在在另一个页面上,我在不使用分页的情况下加载图像,我没有遇到这个问题。。因此,我100%确信这与分页功能有关。

现在,如果用户单击paining部分内的第一个图像,则上述功能将起作用,但如果他执行一些分页操作,然后单击一个图像,则显示的范围将与图片无关。。可以创建stacksnippets,JSFIDLE来演示吗?allcaptions.length是否等于您拥有的照片数?@hristogorgiev是相同的,但问题在于,当您进行分页时,lu中li的顺序会发生变化,这就是为什么如果我从第一张图像开始,它会起作用,如果我进行一些分页,将得到不同的分页。因此,我可以基于图像URL或名称而不是当前所做的基于序列的跨度选择吗?那里的图像变量如何?我没有所有的代码,但我认为这是当前的图像。通过这样做,您可以获得当前图像的标题吗$您可以尝试在单击事件上从dom获取图像,然后选择其相邻的标题