I'm having trouble with setting variables for some opening and closing menus. I need to have a variable I can query as I have other click functions going on that will open and close different menus, so I can't use a toggle.
I don't understand why the following code does not work. Please could someone advise as I can't quite get it, I understand variable scope, but I think the way the jQuery does the click function is confusing me. Or perhaps there is a better pattern to follow for this kind of functionality..
var opentags = false;
$('a#tags').click(function () {
if (opentags == true) {
$('nav#tags').slideUp();
// and other stuff
var opentags = false;
} else {
$('nav#tags').slideDown();
// and other other stuff
var opentags = true;
}});
Thanks in advance.