Answers for "how to disable bootstrap prev(next) arrow on first(last) slide"

0

how to disable bootstrap prev(next) arrow on first(last) slide

$('.carousel').carousel({
    interval: false,
})

$(document).ready(function () {               // on document ready
    checkitem();
});

$('#myCarousel').on('slid.bs.carousel', checkitem);

function checkitem()                        // check function
{
    var $this = $('#myCarousel');
    if ($('.carousel-inner .item:first').hasClass('active')) {
        // Hide left arrow
        $this.children('.left.carousel-control').hide();
        // But show right arrow
        $this.children('.right.carousel-control').show();
    } else if ($('.carousel-inner .item:last').hasClass('active')) {
        // Hide right arrow
        $this.children('.right.carousel-control').hide();
        // But show left arrow
        $this.children('.left.carousel-control').show();
    } else {
        $this.children('.carousel-control').show();
    }
}
Posted by: Guest on November-16-2020

Code answers related to "how to disable bootstrap prev(next) arrow on first(last) slide"

Code answers related to "Javascript"

Browse Popular Code Answers by Language