ElGabbu ElGabbu - 5 months ago 19
HTML Question

html anchor works only once

I am ashamed to say that I have an anchor issue.

So I have this code:

<a name="map"></a>

$("div.store_list").click(function() {
//do some stuff
location.href = location.href + '#map'
});


When doing the first click it works fine. And the URL changes to:

http://mydomain.local/stores#map


Second click the URL changes to the following and it doesn't work:

http://mydomain.local/stores#map#map


Any suggestions? Thanks

Answer

Issue was solved using: document.location = "#map";