vendredi 23 novembre 2018

Variable from if statement - jQuery

Why does console.log() shows A and not B? How do I get it to show B from the variable set in the if statement when the #input changes value?

var myNumber = 1;
var myLetter = 'A';

if( myNumber == 1 ){
    myLetter = 'B';
}

$('#input').change(function(){
    console.log( myLetter );
});

Aucun commentaire:

Enregistrer un commentaire