Previous slide 2 in make an interactive website


#1

i cant get passed this slide i type what the description says and this is what they reply with Oops, try again. Remember to fade out the current slide and remove the 'active-slide' class."


#2

Hi jaime,

Please post and format (select code in editor, Ctrl + K) your code so we can help you.


#3

uhh me too, can't get passes. This code is too long for my imagination :wink:

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(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');
$('.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);


#4

@vesela1 Please create a new topic with your code, error message, and exercise number, so we can help you - hijacking someone else's topic isn't a kindness to anyone.
Thanks :)


#5

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(nextSlide.length == 0) {
nextSlide = $('.slide').first();
nextDot = $('.dot').first();
});

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

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

$(document).ready(main);


#6
is this what you mean ?

#7

Yes, that's exactly what I meant :)

Your code has a few things that need to be fixed:

  • Line 18 should only have the closing curly brace (}), not a closing parenthesis ()) as well
  • Line 19 needs both a closing brace and a closing parenthesis
  • You should remove the current/nextDot stuff in the $('.arrow-prev') click function()
  • You need this:

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

inside the $('.arrow-prev') click function(), between the variables and the slides fading

  • And you accidentally are trying to fadeIn() nextSlide, but it should beprevSlide

Good luck with the rest of the course!