Help? It's saying Oops, try again. Remember to fade out the current slide and remove the active-slide class (Solved)


#1



Help? I have no idea about what the Java Script needs. It wants me to type this:
$('.arrow-prev').click(function() {
var currentSlide = $('.active-slide');
var prevSlide = currentSlide.prev();

if(prevSlide.length == 0) {
prevSlide = $('.slide').last();
}

currentSlide.fadeOut(duration).removeClass('active-slide');
prevSlide.fadeIn(duration).addClass('active-slide');
});

Here's a link to my exercise and here's my code:

https://www.codecademy.com/courses/web-beginner-en-seyrq/0/9?content_from=make-an-interactive-website%3Ajquery-effects#

It says Oops, try again. Remember to fade out the current slide and remove the active-slide class.

var main = function(); {
  $('.dropdown-toggle').click(function() {
    
  });

  $('.arrow-next').click(function() {
    
  });

  $('.arrow-prev').click(function() {
    var currentSlide = $('.active-slide');
    var prevSlide = currentSlide.prev();
    
    if(prevSlide.length == 0) {
        prevSlide = $('.slide').last();
    }   

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

};

$(document).ready(main);


#2

It says the same for me.


#4

Did it work or not? I've been stuck on this for a long time and I couldn't find anything that would help.


#5

Please? I need help quick...


#6

@harbeag7966 You've got your nextSlide and prevSlide code all mixed up. The first thing you should do is try to separate that code out each into it's own click event listener on the previous or next arrow.


#7

What exactly do you mean? I'm still confused.


#8

@harbeag7966 You can't have the code that moves you to the next slide and the code that takes you to the previous slide together. Try to separate it out into the two different click event listeners.

Or, you could go back to the first exercise in this lesson and reset the code on each exercise to start over.


#9

The code can be very sensitive to things being in the wrong place, it might be a good idea to rearrange the code a little bit.


#10

Ok, I just fixed the code. Thank you very much guys!


#11

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.