mardi 25 juin 2019

Conditional Statement Not Working in ie11 for Setting CSS Display

There's a strange occurrence with my conditional statement in ie11: if the first two conditions are false and code runs just the else, successMessage display is set to block as expected.

For some reason, let's say condition 2 is false, then is subsequently updated to true, the else code block doesn't set display to block, however the console did log the message.

Of course everything works well in modern browsers.

CSS:

.alert-success {
  display: none;
}

JS:

handleSubmit = () => {

  let successMessage = document.querySelector('.alert-success');

  if ( condition 1 ) {
   // do something
  } else if ( condition 2 ) {
   // do something else
  } else {
    successMessage.style.display = 'block'
    console.log('Did this render?');
  }

}

Aucun commentaire:

Enregistrer un commentaire