Created
November 11, 2013 18:14
-
-
Save csknk/7417660 to your computer and use it in GitHub Desktop.
Javascript for all pages - mobile responsive menu and back to top button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery(document).ready(function($) { | |
| // Responsive Menu | |
| // prepend menu icon | |
| $('#nav_wrap').prepend('<div id="menu_icon">Menu</div>'); | |
| // toggle nav | |
| $("#menu_icon").on("click", function(){ | |
| $('#menu-main-menu').fadeToggle(700); | |
| }); | |
| // Back to Top Navigation | |
| // Show or hide the sticky footer button | |
| $(window).scroll(function() { | |
| if ($(this).scrollTop() > 200) { | |
| $('.go_top').fadeIn(200); | |
| } else { | |
| $('.go_top').fadeOut(200); | |
| } | |
| }); | |
| // Animate the scroll to top | |
| $('.go_top').click(function(event) { | |
| event.preventDefault(); | |
| $('html, body').animate({scrollTop: 0}, 300); | |
| }) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment