by
back

How to get the Bootstrap Slider/Carousel event with jQuery.

Setup your carousel with the ID js-carousel for example:

<div class="carousel slide" data-ride="carousel" id="js-carousel">
...
</div>

Run your jQuery code when the document has loaded. Trigger the Bootstrap3 carousel events with the slide.bs.carousel and slid.bs.carousel events.

<script type="text/javascript">
    $(document).ready(function() {
    $('#js-carousel').on('slide.bs.carousel', function () {
           console.log("sliding started");
         });
         $('#js-carousel').on('slid.bs.carousel', function () {
           console.log("sliding ended");
         });
    });
</script>

Cheers,
Flo

comments powered by Disqus