Why did I add the class next left in my boostrap carousel when I told him to add my active class in my boostrap carousel?

0

What I want to do is that when my question has a timer and the user next, that question disappears and I can not answer it anymore.

Code:

var timer = $(".active").attr('data-timer');
if (timer == undefined) {
    var $carousel = $('#carousel');
    var NextElement = $carousel.next('.item').first();
    NextElement.addClass('active');
    $('.timer').remove();
} else {
    var $carousel = $('#carousel');
    var ActiveElement = $carousel.find('.item.active');
    ActiveElement.remove();
    var NextElement = $carousel.next('.item');
    NextElement.addClass('active');
    $('.timer').remove();
}

It does everything, except that when it enters the else instead of adding me the active in my carousel it adds the class next left.

Instead of that class being added, it should be active, so when it re-enters the if the slide does not work anymore.

Even add the following:

var NextElement = $carousel.next('.item');

But it still does not work

    
asked by David 10.08.2018 в 23:48
source

1 answer

0

I think that when you use the attr () function you need to add a parameter

$(selector).attr(attribute,value)

You can check this documentation and check if it's the problem Javascript attr ()

    
answered by 11.08.2018 в 03:50