I want to make a menu that opens when you click a button and closes when you click on any part of the screen. The problem is that the menu closes when you click anywhere, except for the open button. According to my idea, after opening the menu, the class at the button is removed and it should become inactive, which means it becomes the same as any part of the document, but for some reason this does not happen. What's my mistake?
$(document).ready(function() { $(hidden).slideUp(); $('.switch').click(function() { $(hidden).slideDown(300); $('#drop-but').removeClass('switch'); return false; }); $(document).click(function() { $(hidden).slideUp(300); $('#drop-but').addClass('switch'); }); });