Initializes the carousel with an optional options object and starts cycling through items. Options object can have following properties:
interval - the amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle. Default value 5000.
keyboard - a boolean value, that defines whether the carousel should react to keyboard events.
pause - value "hover" pauses the cycling of the carousel on mouse enter event and resumes the cycling of the carousel on mouse leave event. Value false defines that hovering over the carousel won't pause it.
wrap - a boolean value, that define whether the carousel should cycle continuously or have hard stops.
touch - a boolean value, that defines whether the carousel should support left/right swipe interactions on touchscreen devices.
You also can specify options as the HTML atribures data-*, for example the data-interval="2000" attribute.
carousel('cycle')
Cycles through the carousel items from left to right.
carousel('pause')
Stops the carousel from cycling through items.
carousel(toFrameInd)
Cycles the carousel to a particular frame, index is 0 based.
carousel('prev')
Cycles to the previous item.
carousel('next')
Cycles to the next item.
carousel('dispose')
Destroys an element’s carousel.
$('.carousel').carousel({
interval: 2000
});
events
event
description
slide.bs.carousel
Fires immediately when the slide method is invoked.
slid.bs.carousel
Fires when the carousel has completed its slide transition.
Both events have the following additional properties:
direction - the direction in which the carousel is sliding, either "left" or "right".
relatedTarget - the DOM element that is being slid into place as the active item.
from - the index of the current item.
to - the index of the next item.
$('#myCarousel').on('slide.bs.carousel', function () {
// do something...
});