私はそのようなコードを持っています:
$(e).click(function() {
console.log(this.href);
location.hash = this.href;
});
e
これは次の<li>
ような要素です: <li href="#about">About</li>
location.hash
onchange リスナーを持っています:
$(window).hashchange(function() {
if (location.hash=="") location.hash="me";
$(".content").spin();
$(".content").load("http://example.com/inc/"+location.hash.substr(1), function() {
$(this).spin(false);
});
});
UPD: console.log は変数の正しい値を出力するため、変数へのアクセスに問題はありません。