i'm trying to use jCarousel but I need to remove the prev control when the carousel hits the first item of the list.
I tried (view fiddle) but it only happens when I click one time more on prev control.
Here is the fiddle:
i'm trying to use jCarousel but I need to remove the prev control when the carousel hits the first item of the list.
I tried (view fiddle) but it only happens when I click one time more on prev control.
Here is the fiddle:
That's because it takes 100 milliseconds to run the sliding animation, and the if statement is being run at the beginning, when the CSS top property has -60 px.
If you set a timeout call, it will work fine:
$('a.glist-prev').click(function () {
setTimeout(function(){
if (parseInt($('ul.ganhadores-list').css('top')) === 0) {
$('a.glist-prev').addClass('disabled');
}
},200);
});
Update: My answer is related to the reason why your code doesn't work. It's not an implementation. You can find a proper example on the official website.
(function($) {
$(function() {
$('.jcarousel').jcarousel();
$('.jcarousel-control-prev')
.on('jcarouselcontrol:active', function() {
$(this).removeClass('inactive');
})
.on('jcarouselcontrol:inactive', function() {
$(this).addClass('inactive');
})
.jcarouselControl({
target: '-=1'
});
$('.jcarousel-control-next')
.on('jcarouselcontrol:active', function() {
$(this).removeClass('inactive');
})
.on('jcarouselcontrol:inactive', function() {
$(this).addClass('inactive');
})
.jcarouselControl({
target: '+=1'
});
});
})(jQuery);