mardi 19 février 2019

How to get an if statement working with variable inside

This is my code but I cannot get the if statement to stop running based on the condition. It's like the function thinks the variable is always 0 even though i'm adding one every time.

var this_current_position = 0;
var numItems = 8;

if (this_current_position <= 4 ) {
    $(".fa-arrow-right").click(function(){
            $('.mobile-gallery-content').animate({"left": '+=-324'});
            this_current_position += 1;
    });
};

Can anyone find any mistakes in my code?

Aucun commentaire:

Enregistrer un commentaire