1
<script>    

     $(".pagebg").on('click', function(d) {
        d.preventDefault();
        $("#dnnMenu").removeClass('nav-open');
        $("#google").removeClass('search-open');
    });

    </script>

I'm trying to Hide the Menu When I click outside of the div. It does Exactly What I want it to do. But when I click on the links they don't work since when I click on the link it just thinks its the body and hides the menu.

Daniel Rubio
  • 49
  • 12
  • duplicate of http://stackoverflow.com/questions/152975/how-to-detect-a-click-outside-an-element – Safari Nov 19 '15 at 18:23

1 Answers1

1

Use stopPropagation method on the click event of your links/ menu div so it won't execute the click event of the outside container (body)

 $(function(){

     $(".someLinks").click(function(e){
       e.stopPropagation();
       // to do : Hide or show
     });

 });
Shyju
  • 214,206
  • 104
  • 411
  • 497