Skip to content

Instantly share code, notes, and snippets.

@MikeRixWolfe
Created June 4, 2019 04:12
Show Gist options
  • Save MikeRixWolfe/681f2ebbd29730a6ada3f777508c0bbf to your computer and use it in GitHub Desktop.
Save MikeRixWolfe/681f2ebbd29730a6ada3f777508c0bbf to your computer and use it in GitHub Desktop.
$(window).on("load", function () {
hashRoute(location.hash.replace('#', '') || "index");
});
$(window).on('hashchange', function () {
hashRoute(location.hash.replace('#', ''));
});
function hashRoute(route) {
$("html, body").animate({ scrollTop: 0 }, "fast");
//$("section").load(route);
if (route.length > 0 && $("#hashrouter>#" + route).length > 0) {
$("#hashrouter").children().hide();
$("#hashrouter>#" + route).show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment