Why does == break my if else statement?


My code:

var main = function(){
    var currentSlide = $('.active-slide');
    var nextSlide = currentSlide.next();
    if (nextSlide.length === 0) {
        nextSlide = $('.slide').first();

My code works perfectly with one = but fails with == in the line below:

nextSlide = $('.slide').first();

Is it simply incorrect syntax to use == or === for the if else statement?


To assign values, a single equal sign is used. So, you would only use one equal sign like you are doing now. Here is a link in a jQuery excercise that might help you.:slight_smile:



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