This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by nickw1235
over 9 years

"Oops, try again. Make sure you have defined all the variables!" Need help!

I’m pretty much stuck here. I know I must be missing something obvious. Some help would be appreciated! Here is my code:

var main = function() { $(‘.dropdown-toggle’).click(function() { $(‘.dropdown-menu’).toggle(); });

$('.arrow-next').click(function() {
    var currentSlide = $('.active-slide');
    var nextSlide = currentSlide.next('.active-slide');
    
    var currentDot = $('.active-dot');
    var nextDot = currentDot.next();
    
    if(nextSlide.length === 0) {
        nextSlide = $('.slide').first();
        $('.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();
    
    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');
    nextDot.addClass('active-dot');
    

});

};

$(document).ready(main);

Answer 54baf77fd3292ffee0002a8c

1 vote

Permalink

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

points
Submitted by Nikola
over 9 years

1 comments

realityrepair about 9 years

not bad man thanks i think there is something going on when we are copying and pasting from ides notepads or hints to the compiler

Answer 54b854529376767623003d64

0 votes

Permalink

Does anyone know what mistake I made here?

points
Submitted by nickw1235
over 9 years

Answer 54b89f7b95e37883bb00481d

0 votes

Permalink

In the block of $(‘.arrow-prev’).click(function() {, you don’t define currentDot abd nextDot.

points
Submitted by kongling893
over 9 years

1 comments

nickw1235 about 9 years

This fixed my issue. Thanks!