Skip to content

Instantly share code, notes, and snippets.

@noeljackson
Created April 8, 2013 23:21
Show Gist options
  • Save noeljackson/5341464 to your computer and use it in GitHub Desktop.
Save noeljackson/5341464 to your computer and use it in GitHub Desktop.
Get a location.hash and then do stuff
var url = window.location.hash.toString();
var anchor = '#' + url.split('#')[1];
//if a hash is in a url, show that div
if (url.match('#')) $(anchor).show();
// if the hash changes, show that div
$(window).bind('hashchange', function() {
$(anchor).show();
});
// this is simple and can be written more elegantly, but will get you where you need to go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment