Skip to content

Instantly share code, notes, and snippets.

@atomgroom
Created November 30, 2016 21:04
Show Gist options
  • Save atomgroom/b10094f21ae5c982f9090b76cf02e22c to your computer and use it in GitHub Desktop.
Save atomgroom/b10094f21ae5c982f9090b76cf02e22c to your computer and use it in GitHub Desktop.
// Below is the menu on mobile that opens the menu
<a class="mobile-menu-icon" onclick="javascript:toggle('menu');">
<img src="/images/icon-menu.svg" />
MENU
</a>
// Then there is some markup for the menu
// This script toggles the menu open and close, jumps the page to the top, and onWindow.Resize toggles the display (for responsive).
<script type="text/javascript">
<!--
function toggle(id) {
var e = document.getElementById(id);
e.style.display == 'block' ? e.style.display = 'none' : e.style.display = 'block';
window.scrollTo(0, 0);
window.onresize = function(){
e.style.display = '';
};
}
//-->
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment