Function will not execute

I am trying to create a function that will be executed by clicking, provided that the variable is set to 0;

However, the function will not execute even if the variable is set to 0. (I use jquery)

var menuVisible = 0 ;
$('#links').click(function(){ 
    if (menuVisible = 0)
    {
        $('#subMenu').show("slow") ;
        menuVisible = 1 ;
    }
});

I am testing the value of the "MenuVisible" variable with a warning, and it really is "0". So why the function will not execute?

+3
source share
4 answers

, . "/" ( , , , ), hide()/show() toggle(). :)

+2

:

if (menuVisible = 0)

false ( 0). :

if (menuVisible == 0)
+8

if :

if (menuVisible == 0)

. .

+4

:

if (menuVisible = 0)

if (!menuVisible)

.

+2

Source: https://habr.com/ru/post/1729864/


All Articles