Open / Close menu on button click with jQuery

iuqadnam

New Member
I just ran into a problem. On my site I need to have possibility to open or close menu item by click of the button. On button click : \[code\]var checked = true;function NotifierButtonClicked() { if (checked == true) { checked = false; GetNotificationsForUser(); $('.selectBox').slideToggle(200).css('borderTop', 'none'); $('.selectBox li').click(function () { $('.selectBox').slideUp(200); }); } if (checked == false) { checked = true; $('.selectBox').slideUp(200); }}\[/code\]So problem here is that when I enter \[code\]if block\[/code\] first time, \[code\]checked\[/code\] is true, so I slide menu up and set \[code\]checked\[/code\] to be true. Next time I click on button checked is true so menu will open up, but I set checked to be false so when code gets to next if condition it will run too and close menu right away. How to solve this problem?
 
Back
Top