Add Play/Pause button to bootstrap carousel

后端 未结 3 1879
孤城傲影
孤城傲影 2020-12-14 03:58

I have read almost all the threads regarding to the bootstrap carousel, but haven\'t found an answer to my question. I have added two control buttons (play/pause) to the car

3条回答
  •  太阳男子
    2020-12-14 04:26

    This was my approach. You can style the .pause and .play class however you see fit, but I'm just using plain text for demo purposes:

    $('.carousel-control.pause').click(function() {
            var controls = $(this);
            if (controls.hasClass('pause')) {
                controls.text('Resume').removeClass('pause').toggleClass('play');
                $('#myCarousel').carousel('pause');
            } else {
                controls.text('Pause').removeClass('play').toggleClass('pause');
                $('#myCarousel').carousel('cycle');
            }
        });
    

    Here is your detonator

    Pause
    

提交回复
热议问题