Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('.carousel').carousel();
- var caption = $('div.item:nth-child(1) .carousel-caption');
- $('#right').html(caption.html());
- caption.css('display','none');
- $(".carousel").on('slide.bs.carousel', function(evt) {
- var caption = $('div.item:nth-child(' + ($(evt.relatedTarget).index()+1) + ') .carousel-caption');
- $('#right').html(caption.html());
- caption.css('display','none');
- });
- <p id="right"></p>
- $(document).ready(function() {
- var url = document.location.toString();
- var totalItems = $('.item').length;
- //Initiate carousel
- $('.carousel').carousel({
- interval: false
- })
- $('.carousel').on('slid.bs.carousel', function () {
- var currentIndex = $('div.active').index() + 1;
- //Update pager-text
- $('.pager-text').text(''+currentIndex+'/'+totalItems+'');
- // Update location based on slide (index is 0-based)
- window.location.hash = "#"+ parseInt($('.carousel .carousel-inner .item.active').index()+1);
- });
- if (url.match('#')) {
- // Clear active item
- $('.carousel .carousel-inner .item.active').removeClass('active');
- // Activate item number #hash
- $('.carousel-inner div:nth-child(' + url.split('#')[1] + ')').addClass('active');
- //Update pager-text
- $('.pager-text').text(''+url.split('#')[1]+'/'+totalItems+'');
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement