I am thinking that if we use $('overlay-menu').hidden = (id === 'nocard'); instead of adding the "hidden" class to overlay-menu in every case, will that be simpler and easier to understand? also we probably don't have to depend on the change of CSS property in the "hidden" class.