Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.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 第一次使用jquery滑块时隐藏.prev按钮_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 第一次使用jquery滑块时隐藏.prev按钮

Javascript 第一次使用jquery滑块时隐藏.prev按钮,javascript,jquery,html,css,Javascript,Jquery,Html,Css,当这是第一次时,如何隐藏按钮.prev? 为什么滑块在最后一次单击时返回到第一张幻灯片。上一页?我怎样才能解决这个问题 var nextPane = function (e) { e && e.preventDefault(); var $container = $(this).closest('.grid-container'); var $items = $('.items', $container);

当这是第一次时,如何隐藏按钮.prev? 为什么滑块在最后一次单击时返回到第一张幻灯片。上一页?我怎样才能解决这个问题

    var nextPane = function (e) {
        e && e.preventDefault();
        var $container = $(this).closest('.grid-container');
        var $items = $('.items', $container);
        var offset = $items.css('marginLeft').replace('px', '');
        var width = $container.width() + parseInt($('.item', $container).css('marginRight').replace('px', ''));
        $items.css('marginLeft', offset - width);

        if($(this).parent().find('.items').width() + (offset - width) < width){
            $(this).hide();
        }

    }

    var prevPane = function (e) {
        e && e.preventDefault();
        var $container = $(this).closest('.grid-container');
        var $items = $('.items', $container);
        var offset = $items.css('marginLeft').replace('px', '');
        var width = $container.width() + parseInt($('.item', $container).css('marginRight').replace('px', '')); 
        $items.css('marginLeft', offset + width);


        if($('.next').is( ":hidden" )){
            $(this).parent().find('.next').show();
        }
    }
var nextPane=函数(e){
e&e.preventDefault();
var$container=$(this).closest('.grid container');
变量$items=$('.items',$container);
var offset=$items.css('marginLeft')。replace('px','');
var width=$container.width()+parseInt($('.item',$container.css('marginRight')).replace('px','');
$items.css('marginLeft',offset-width);
if($(this).parent().find('.items').width()+(offset-width)

由于您不返回一张幻灯片,而是始终返回上一张幻灯片上的第一张幻灯片,因此当您单击“下一步”或“上一步”时,您可以只
隐藏()
显示()
上一张幻灯片

单击“下一步”时

$(this).parent().find('.prev').show();
单击“上一步”时

$(this).parent().find('.prev').hide();

上帝。。。您如何控制您正在观看的幻灯片?此外,每次单击其中一个按钮时,都会获得对所有jQuery对象的引用。你为什么不存储它们的外部引用?@Oscar Paz谢谢,你能帮我一下吗?我很难理解你在做什么,因为你不提供标记和CSS。你怎么知道你在看哪张幻灯片?我建议你提供一个伴侣,是的,我提供了所有关于我的问题我的代码:-)@Oscar Paz你能帮我一把吗?谢谢,干得好!如果单击“上一页”返回到第一张幻灯片,如何防止在最后一张幻灯片上出现?因此,在单击“上一页”时,您不想返回到第一张幻灯片?如果是这样,那么这个修复是不好的。我想在第一张幻灯片上隐藏上一张幻灯片,但是当我在最后一张幻灯片上单击上一张时,如果我单击上一张幻灯片,那么我应该能够隐藏上一张幻灯片而不是第一张幻灯片。这有意义吗?