Last Updated: July 27, 2016
·
3.635K
· iatek

Bootstrap Carousels

Dual sliders example. One carousel for thumbnails, and a larger carousel for full size images. Uses the Bootstrap 3 Carousel component. The thumbnail slider shows 4 images at a time.

// handles the carousel thumbnails
$('[id^=carousel-selector-]').click( function(){
  var id_selector = $(this).attr("id");
  var id = id_selector.substr(id_selector.length -1);
  id = parseInt(id);
  $('#myCarousel').carousel(id);
  $('[id^=carousel-selector-]').removeClass('selected');
  $(this).addClass('selected');
});

// when the carousel slides, auto update
$('#myCarousel').on('slid', function (e) {
  var id = $('#myCarousel .item.active').data('slide-number');
  id = parseInt(id);
  $('#thCarousel [id^=carousel-selector-]').removeClass('selected');
  $('#thCarousel .item.active [id^=carousel-selector-'+id+']').addClass('selected');
});

http://www.bootply.com/116972

1 Response
Add your response

nice!

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside