mercredi 28 septembre 2016

someone gave me a code can someone please explain it to me [on hold]

someone gave me this code and it worked with me but I didn't understand the code very well

the z1 ,z2 and z3 are pictures (I don't want an explanation for the them) i just want an explanation for the job of (if statement) and the variable here how did he use them, what is there job?

var firstClick = true;

$('.button').click(function() {
    if (firstClick){
        $('.z1').replaceWith($z2);
        firstClick = false;

    }else{
        $('.z2').replaceWith($z3);    
        firstClick = true;

    }
});

Aucun commentaire:

Enregistrer un commentaire