<a href="#anchor1" id="example" onclick="{this.hash=(this.hash=='#anchor1')?'#anchor2':'#anchor1'}" >Нажми сюда</a>