javascript - CSS style not reverting using Javacript -
i trying set css property , forth using javascript depending on value @ time. class name 'menu' set hidden on page load. when call set visible successful. however, when call again change doesn't set hidden. seen set visible.
let menu = document.queryselector('.menu'); if (menu.style.visibility = 'hidden') { menu.style.visibility = 'visible'; console.log('visible'); // shows this. } else { menu.style.visibility = 'hidden'; console.log('hidden'); // doesn't here when .menu visible. }
i confused why can first not second. have tried having specific else: else if (menu.style.visibility = 'visible')
tried using setattribute it's same outcome.
i need able switch , forth.
kindly use below condition
if (menu.style.visibility == 'hidden') //change ==
Comments
Post a Comment