This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Interactive Website: Flipboard Forum

View Course

976 points
Picture
Submitted by
Jambari
about 3 years ago

7/12 Dunno what's wrong

can anyone show me what part of these codes which is wrong ?

if(nextSlide.length == 0){
nextSlide = $('.slide').first();
nextDot = $ ('.dot').first();
}

when I click save & submit it appears
"
Oops, try again. When on the last slide, it looks like next arrow isn't wrapping back to the first dot. Look back at the instructions and check the code inside the if statement."


0 votes

permalink

Same problem at that point.
Does anyone know what the reason might be?

Edit:
I rearranged my code and it works now.

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

      });

558 points
3c7de2ddc1fe1daece59c65c12621991?s=140&d=retro
Submitted by
Venjai
about 3 years ago


0 votes

permalink

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();
    var currentDot = $('.active-dot');
    var prevDot = currentDot.prev();

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

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

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

};

$(document).ready(main);

570 points
09161eb479eb670e8d557d9b917b9aaa?s=140&d=retro
Submitted by
Maximilian Kellringer
about 3 years ago

1 Comment

Ea7001aeab3eb27c19f5ed8b05b72021?s=140&d=retro ColmMcG1 about 3 years ago

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();
var currentDot = $('.active-dot');
var prevDot = currentDot.prev();

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

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

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

});
};

$(document).ready(main);