I am trying to change a hashed URL (document.location.hash) with the replace method, but it doesn't work.
$(function(){
var anchor = document.location.hash;
//this returns me a string value like '#categories'
$('span').click(function(){
$(window).attr('url').replace(anchor,'#food');
//try to change current url.hash '#categories'
//with another string, I stucked here.
});
});
I dont want to change/refresh page, I just want to replace URL without any responses.
注意:我不想用href="#Food"解决方案来解决这个问题.