i want to add a class to body if #myModal's display is block and remove the class when #myModal's display changes to none. I applied the following code but it isn't working.
<script>
var body = document.body
var modal = document.getElementById('myModal')
if (modal.style.display = 'block') {
body.classList.add('hide');
}
if (modal.style.display == 'none') {
body.classList.remove('hide');
}
</script>
Aucun commentaire:
Enregistrer un commentaire