-1

I am trying to add several conditions to a single IF statement but I cannot figure out why it does not work. I tried to switch to == and ===, but it did not work either. My code does work, however, if I only use one condition (only div_1, without div_2, div_3). Can I use && with styles or is there is different way to do that? Or what is wrong with my code?

        btn_next.addEventListener('click', () => {
            if (div_1.style.visibility = "hidden" && div_2.style.visibility = "hidden" && div_3.style.visibility = "hidden" ) 
            {div_1.style.visibility = 'visible'}
            else {
                console.log("Hello")
            }

        })

I would expect that the div_1 will become visible if I click on the button when all three divs are invisible.

n_che
  • 1
  • 1
  • 3
    You are ***assigning*** in your condition, not *comparing*. – deceze Aug 05 '23 at 06:14
  • Give us a complete [mre], with fixed `==` signs as well. Assuming you fix the condition check, there's nothing wrong with it per se. – deceze Aug 05 '23 at 15:55

0 Answers0