jquery - Click icon, pop up div, and click elements except div disappear -


.menuleft menu icon. .mainmenu whole div menu pop up. following code, works fine except when mainmenu on, clicking .menuleft let .mainmenu disappear , pop again...

other types of ways more welcome. cheers.

        $(document).ready(function(){             $('.menuleft').click(function() {             $('.mainmenu').slidetoggle('fast');              });             $(document).mouseup(function (e){                 var container = $('.mainmenu');                  if (!container.is(e.target)                     && container.has(e.target).length === 0)                 {                     container.hide('slow');                 }             });          }); 

html following:

      <div class="headermain mobile_disappear">       <div class="container">     <div class="menuleft cur">         <i class="fa fa-bars"></i>     </div>     <div class="mobilelogo">         <?php echo '<a href="'. home_url() .'"><img src="' . get_stylesheet_directory_uri() . '/images/logo.gif" /></a>'; ?>      </div>     <div class="menuright cur">         <i class="fa fa-user"></i>     </div> </div> 


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -