I need to hide the previous button on the first item, and hide the right button when the carousel on the last item.
I know there is other same questions as mine but I really really cound’t make it work, if someone can help and explain to me how it works for caroussel bootstrap i’ll be really gratefull Thanks in advance for your help.
Here is my slider it’s a tabed slider : http://codepen.io/hafsadanguir/pen/ZONxvV
(function($) {
$(document).ready( function() {
$('#myCarousel').carousel({
pause: true,
interval: false
});
$(".prev-slide").click(function(){
$("#myCarousel").carousel('prev');
});
$(".next-slide").click(function(){
$("#myCarousel").carousel('next');
});
var clickEvent = false;
$('#myCarousel').on('click', '.nav a', function() {
clickEvent = true;
$('.nav li').removeClass('active');
$(this).parent().addClass('active');
}).on('slid.bs.carousel', function(e) {
if(!clickEvent) {
var count = $('.nav li').length -1;
var current = $('.nav li.active');
current.removeClass('active').next().addClass('active');
var id = parseInt(current.data('slide-to')) +1;
if(count+1 == id) {
$('.nav li').first().addClass('active');
}
}
});
});
})(jQuery);
3
Answers
Add this to your css:
Just look in the html.
Do
ctrl
+f
on your html file.And type in next or previous. You will see the next and previous classes stand.
Just remove them.
You can change the display property of a control by the
.css()
method.Use the
slid.bs.carousel
event to hide an arrow. If an item has the.active
class at this point, it means that the item has just become active.Use the
slide.bs.carousel
event to show an arrow. If an item has the.active
class at this moment, it means that the item becomes inactive right now.Please check the result. Is it what you want to achieve?
http://codepen.io/glebkema/pen/EgawBK