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');
});
Written by Carol Skelly
Related protips
1 Response
nice!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Filed Under
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
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#