Help with 8. Previous slide 1


#1

Hi all,

im getting

Oops, try again. It looks like previous arrow isn't moving back to the previous slide. Look back at the instructions and check the $('.arrow-prev').click() event handler

When trying to use the hint text, which was the same as what i'd typed before using the hint code to the same results.

Its incredibly frustrating having a teacher that gets as stuck as the student... I was unable to find anything that worked on the forum either.

Any help greatly appreciated.

Here is the code.

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');
  var nextDot = currentDot.next();
  
  if (nextDot.length === 0) {
      nextSlide = $('.slide').first();
      nextDot = $('.dot').first();
  }
  
  
  
  currentSlide.fadeOut (600).removeClass('.active-slide');
  nextSlide.fadeIn(600).addClass('.active-slide');
  
  currentDot.removeClass('active-dot');
  nextDot.addClass('active-dot');
  
});

 $('.arrow-prev').click(function(){
    var currentSlide = $('.active-slide');
    var prevSlide = currentSlide.prev();
    
    currentSlide.fadeOut(600).removeClass('active-slide');
    prevSlide.fadeIn(600).addClass('active-slide');
  });
}

$(document).ready(main);

#2

Hi Fatlarry,

On lines 22 and 23, you need to remove the dot (.) inside the parenthesis (()) for addClass() and removeClass().

The reason for this is that the dot is used to identify the selector as being a class selector - you can also have id (#id) selectors, or tag name (tag) selectors, as the most basic ones.
But with addClass(), removeClass(), or toggleClass(), the computer knows it's dealing with a class, so that distinction isn't necessary :slightly_smiling:


#3

Thank you. I wish the application could tell us these issues.


#4

A post was split to a new topic: Need help on "Previous Slide 1" (ex. 8)


#5