Created
January 18, 2011 21:18
-
-
Save tadast/785171 to your computer and use it in GitHub Desktop.
how to prevent anchor links from scrolling to id element but update address bar with hash (useful for some sort of tabs)
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
$("<clickable anchor link selector selector>").click(function(ev){ | |
if (history && history.pushState) { | |
$(function() { | |
history.pushState(null, document.title, this.href+ev.currentTarget.hash); | |
ev.preventDefault(); | |
}); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment