I am writing a jQuery function that relies on knowing the current #anchor of the page. I am using the jQuery URL Parser plugin to get the anchor.
$.fn.vtabs = function() {
alert("Your anchor is "+$.url.attr('anchor'));
}
This code gives me the anchor "#nav" endlessly (I use #nav in some of the my links). I can type in "#newanchor" into the browser bar endless times, and click url's to this page that use different anchors, but always this code gives me "#nav".
I fixed my problem by changing the code to:
var current_anchor = $.url.attr('anchor');
$.fn.vtabs = function() {
alert("Your anchor is "+current_anchor);
}
Now it always gives me the correct anchor. But I don't know why, and it appears messy to have that variable defined outside of the function.