I am currently using this code I found to autoscroll to anchors:
$(function() {
$('nav a[href*=#]').bind('click',function(event){
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top - 100
}, 1000);
event.preventDefault();
});
});
What can I add to make sure that the #anchor gets added to the URL when clicked?
I have seen this used, but I'm not sure how to add it..
function() {
if(history.pushState) {
history.pushState(null, null, target);
}
else {
location.hash = target;
}
});
Thanks very much!!!