Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save slavapas/bafd73bcd1c23f0e141521c895d7a9cb to your computer and use it in GitHub Desktop.
Save slavapas/bafd73bcd1c23f0e141521c895d7a9cb to your computer and use it in GitHub Desktop.
Close fropdown by clicking outside of menu jQuery
$(document).ready( function(){
$('#trigger').click( function(event){
event.stopPropagation();
$('#drop').toggle();
});
// this is the most important part
$(document).click( function(){
$('#drop').hide();
// where #drop is the entire collapsed menu
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment