javascript - Carousel Thumbnails still not auto updating -


building carousel thumbnails, thumbnail should correspond slide displayed , selected thumbnail should have border around let users know slide on. current code has thumbnails selected onclick should auto updating each slide of carousel, have done wrong?

$('#mycarousel').carousel({ interval: 4000 });  // handles carousel thumbnails $('.carousel-selector').click(function () { var selectoridx = $(this).closest('li').index();  $('#mycarousel')   .carousel(selectoridx)   .find('.carousel-selector').removeclass('selected')   .eq(selectoridx).addclass('selected')   .end()   .find('.item').removeclass('selected')   .eq(selectoridx).addclass('active'); }); 

fiddle http://jsfiddle.net/gward90/xr8qzxmg/9/

the best way go use slide.bs.carousel event change "active" thumbnail.

$('#mycarousel').carousel({     interval: 4000 });  var selectoridx = 1; var numitems = $('.carousel-selector').length;  // handles carousel thumbnails $('.carousel-selector').click(function () {     selectoridx = $(this).closest('li').index();     $('#mycarousel').carousel(selectoridx) });  $('#mycarousel').on('slide.bs.carousel', function () {     $('#mycarousel')         .find('.carousel-selector').removeclass('selected')         .eq(selectoridx).addclass('selected')         .end()         .find('.item').removeclass('selected')         .eq(selectoridx).addclass('active');     if (selectoridx < (numitems - 1))         selectoridx++;     else         selectoridx = 0; }); 

jsfiddle


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

wso2esb - How to concatenate JSON array values in WSO2 ESB? -