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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -