Como posso substituir o hash de URL de uma janela por outra resposta?

Eu estou tentando alterar uma URL com hash (document.location.hash) com o método replace, mas não funciona.

$(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.
  });

});

Eu não quero mudar / atualizar a página, eu só quero substituir o URL sem qualquer resposta.

Nota: Eu não quero resolver isso com uma solução href = "# food".

questionAnswers(2)

yourAnswerToTheQuestion