Im using the following example for hash change:
$(window).trigger('hashchange');
$('.navBtn').bind('hashchange',function(){
var hval = location.hash.slice(1); // remove the leading #
alert(hval);
});
But nothing appears to happen, I get no alert. Any ideas why?
You just need
The hash change event is fired on the window. There is no js needed to change the hash. this is handled be the browser. ie clicking on the link will change the hash and the window event ‘hashchange’ will then be fired.