Skip to content

Instantly share code, notes, and snippets.

@csknk
Created November 11, 2013 18:14
Show Gist options
  • Select an option

  • Save csknk/7417660 to your computer and use it in GitHub Desktop.

Select an option

Save csknk/7417660 to your computer and use it in GitHub Desktop.
Javascript for all pages - mobile responsive menu and back to top button
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