I am using bootstrap 4.0 version. I want to hide left control on the first item, and hide the right control on the last item. I think using jQuery it can be solved.
Left control will hide all the time it only show on the last item. And right control will show all the time but hide in the last item.
HTML:
<div id="carousel-1" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
Slide 1
</div>
<div class="carousel-item">
Slide 2
</div>
<div class="carousel-item">
Slide 3
</div>
</div>
<a class="carousel-control-prev" href="#carousel-1" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel-1" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
JQuery:
$('.carousel').carousel({
interval: false,
})
function checkitem()
{
var $this = $('#carousel-1');
if ($('.carousel-inner .carousel-item:first').hasClass('active')) {
$this.children('.carousel-control-prev').hide();
} else if ($('.carousel-inner .carousel-item:last').hasClass('active')) {
$this.children('.carousel-control-next').hide();
} else {
$this.children('.carousel-control').show();
}
}