samedi 8 septembre 2018

"If" condition is not working. How can i compare them both. Also i have tried the value into integer type but it still wont work

var v= document.getElementById('btn');

v.addEventListener('click', action);

var selection = document.getElementById('inputGroupSelect01');

function action(e) { 
  document.getElementById('inputGroupSelect01');
  console.log(selection.value);
  var b = parseInt("selection.value");
  console.log(typeof(b));
  if (b === 2) {
    console.log("congo number is 1");
  } 
  else { 
    console.log('not');
  }
}

Aucun commentaire:

Enregistrer un commentaire