samedi 25 avril 2015

Boolean Jquery While/If

Sorry for the question but i am bad in jquery.

I created a menu on my website which is openable with a click, and i want while/if this menu is opened that the opacity is 0.

I created a variable

var IsOpened = false; //bool 

and in my function:

$('#sidebar-menu, #overlay').click(function() {
    $('.portfolio-full').removeClass('portfolio-open');
    $('#top').removeClass('portfolio-open');
    $('#sidebar-button').toggleClass('open');
    $('#sidebar-menu').toggleClass('open');
    $('body').toggleClass('sidebar-open');
    IsOpened = true;
    return false;
});

and after this code i put:

if (IsOpened = true) {
    $('#top').stop().animate({'opacity':'0'},400);
}

or

while (IsOpened = true) {
    $('#top').stop().animate({'opacity':'0'},400);
}

but this is not working, why?

Aucun commentaire:

Enregistrer un commentaire