简体   繁体   English

Bootstrap Carousel-如何获得幻灯片上的数量

[英]Bootstrap Carousel - How to get the count on slides

I have the same query as the below post, but I couldn't get it to work. 我有与以下帖子相同的查询,但无法正常工作。

Carousel - Twitter BootStrap ; 轮播-Twitter BootStrap; Hiding the Previous or Next button . 隐藏上一个或下一个按钮

  1. Catch the slide/slid event to determine when the first image has finish, then add back the "previous" control? 捕获slide / slid事件,以确定第一个图像何时完成,然后添加回“ previous”控件?
  2. Continue catching slide/slid event, incrementing a counter along the way. 继续捕捉幻灯片/幻灯片事件,并在此过程中增加一个计数器。 when your counter is equal to your list of images, you can remove the "next" control 当计数器等于图片列表时,您可以删除“下一个”控件

Here is my jsfiidle 这是我的jsfiidle

<div id="myCarousel" class="carousel slide">
            <div class="carousel-inner">
                <div class="carousel-inner">
              <div class="active item"><img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-01.jpg">
              </div>
              <div class="item"><img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-02.jpg"></div>
              <div class="item"><img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-03.jpg"></div>
            </div>
            </div>
            <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
        </div>
$(document).ready(function () {

    // -------- Initialise Carousel -------- //
   $('.carousel').each(function(){
        $(this).carousel({
            interval: false
        })
    });
});

I just made a quick example, basically it's listening to the slid event and every time the slide animation is done it will check which one the active slide is, based on that you can check whether it's the first or the last one. 我只是举了一个简短的例子,基本上它是在监听slid事件,每次播放幻灯片动画时,它都会检查活动幻灯片是哪一张,然后您可以检查它是第一张还是最后一张。

http://jsfiddle.net/nRgVJ/5/ http://jsfiddle.net/nRgVJ/5/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM