4

Twitter引导轮播中页面加载后如何隐藏左键?

http://twitter.github.com/bootstrap/javascript.html#carousel

我的尝试(它在第一次行动后起作用,我需要所有时间):

$('#myCarousel').on('slid', '', function() {
    var $this = $(this);

    $this.children('.carousel-control').show();
    if($('.carousel-inner .item:first').hasClass('active')) {
      $this.children('.left.carousel-control').hide();
    } 
    else if($('.carousel-inner .item:last').hasClass('active')) {
      $this.children('.right.carousel-control').hide();
  }

});
4

1 回答 1

1

只需在页面加载后隐藏左侧按钮即可。因为它总是从第一张幻灯片开始。

$('#myCarousel > .left.carousel-control').hide();

或者,在页面加载后手动触发slid事件。

$('#myCarousel').on('slid', '', function () {
  ...
}).trigger('slid');
于 2013-02-17T19:56:21.760 回答