I want to close the navigation menu when the click on outside the menu like body part how can i do that: i attach the code below

  • Please share the URL so that I can check the jQuery you've written is correct or not. – Sumit Sep 26 at 7:05
  • Code is in my local server @Sumit – Magento Sep 26 at 7:07
  • the added jQuery in the question is working fine? – Sumit Sep 26 at 7:08
  • I want to add when the user click on out side the menu bar, currently using above code there is one close button attach with menu bar but when i click on body it can not close – Magento Sep 26 at 7:09
  • OK, let me check. – Sumit Sep 26 at 7:11

Try Below solution

$(document).click(function(event) {
     if (jQuery(event.target).is(".mobile-bar-icon")) {
     } else if(jQuery(event.target).is(".mobile-bar-close") || !$(event.target).is(".mobile-bar-content")) {
  • Its work for me.. Thank you @Ranganathan – Magento Sep 26 at 7:37
  • Welcome...@Magento – Ranganathan Sep 26 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.