Skip to content

Instantly share code, notes, and snippets.

@anacampesan
Created August 18, 2017 20:49
Show Gist options
  • Save anacampesan/3270023f25e54a6e491b071daec98377 to your computer and use it in GitHub Desktop.
Save anacampesan/3270023f25e54a6e491b071daec98377 to your computer and use it in GitHub Desktop.
<script>
document.addEventListener('DOMContentLoaded', function() {
var notificationBtn = document.getElementById('notificationBtn');
var notificationBox = document.getElementById('notificationBox');
document.body.addEventListener('click', function(ev) {
notificationBox.style.display = 'none';
});
notificationBtn.addEventListener('click', function(ev) {
ev.stopPropagation();
notificationBox.style.display = notificationBox.style.display == 'none' ? 'block' : 'none';
});
});
</script>
<button id="notificationBtn">Menu</button>
<div id="notificationBox" style="display: none;">
<ul>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment