Opps Error 7.Next dot 2

jquery

#1

Get Oops error while trying to run code. Please help to find the mistake:

var main = function(){

$('.dropdown-toggle').click(function(){
$('.dropdown-menu').toggle();
});
$('.arrow-next').click(function(){
   var currentSlide = $('.active-slide');
   var nextSlide = currentSlide.next();
   var currentDot = $('.active-dot').removeClass('active-dot');
   var nextDot = currentDot.next().addClass('active-dot');
   
   
   if(nextSlide.length == 0) {
   nextSlide = $('.slide').first();
   nextDot = $('.dot').first();
   }
   
   currentSlide.fadeOut(600).removeClass('active-slide');
   nextSlide.fadeIn(600).addClass('active-slide');
   
});

};

$(document).ready(main);


#3

Hi Mykola,

The problem with your code is that on lines 9 and 10, you're trying to be a bit too efficient. Remove the add/removeClass parts, then add

currentDot.removeClass('active-dot');
nextDot.addClass('active-dot');

Right after where you do the same thing with the slides.
I hope this helps, please let me know if you have any questions!


#4

Hi,
Thank You for the answer. But this code was working well, exept returning Dot to first. Slider returns, but Dot no... I tryied your advices, and it still don't return.
But anyways, thank's for the help.


#5

Now I tried your code once more, and it works :smile:
Thanl's :wink: