Thank you for watching my video please don't forget to LIKE and SUBSCRIBE. My gaming channel: / @jonvadar Support me: www.buymeacoff... My website: jonvadar.xyz/ #javascript #html #css #learnwebdevelopment
Nice video. But sometimes the toggle button may contain other HTML elements too, e.g. , , etc. In that case the code shown in this video will fail to serve the purpose. So we can simply modify the "if" condition a bit to make it work on all cases. The condition will be like this: if(!menu.contains(e.target) && !menuBtn.contains(e.target)) {...}
Thank you. I have a video (ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-xcyfjHhMt28.html) for a mobile menu in which I go over the "click outside" and the repo to that is: github.com/JonVadar/RU-vid_videos/tree/main/Tips%20%26%20tricks%20videos/mobile_menu