Created
April 8, 2013 23:21
-
-
Save noeljackson/5341464 to your computer and use it in GitHub Desktop.
Get a location.hash and then do stuff
This file contains 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
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