I have a simple javascript function to get hash variables:
$(document).ready(function(){
$("a").click(function(){
nav_anchor()
});
function nav_anchor() {
var aurl = location.hash;
aurl = aurl.split('#');
if (aurl[1]) { alert(aurl[1]); }
else { alert("Empty"); }
}
});
<a href="#a=1&aa=10">11111111111</a>
<a href="#b=1&bb=10">22222222222222</a>
<a href="#c=1&cc=10">333333333</a>
But if I click on the link, I get the previous var.
Example:
If my first click 11111, I get a message Empty, and if my second click 222222, I geta=1&aa=10
source
share